[英]JMS setRollbackOnly - inconsistent behaviour
請查看以下消息驅動程序 Bean。 消息進來后,我們對其調用clearProperties()
以解鎖並能夠在其上設置一些其他屬性。 最后,我們在MessageDrivenContext
上調用setRollbackOnly()
以便重新傳遞消息。
我們使用 ActiveMQ 作為消息代理,帶有 JBoss 和相應的activemq-rar.rar
資源適配器。 盡管最近和新版本之間關於此資源適配器關於下面代碼段的行為方式存在差異。 直到版本“5.11.0.redhat-630446”的資源適配器,我們在onMessage
方法中設置的property("newprop")
出現在重新投遞的消息中。 從版本“5.11.0.redhat-630475”開始, clearProperties()
和setObjectProperty()
方法對重新發送的消息沒有影響,因此它屬於onMessage
方法,具有與原始第一條消息相同的屬性。
我想知道哪種行為是正確的?
@MessageDriven(activationConfig = {
@ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
@ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/QUEUE1"),
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue")
})
public class MDBean implements MessageListener {
@Resource
private MessageDrivenContext contextMD;
public void onMessage(Message message) {
try {
message.clearProperties();
message.setObjectProperty("newprop", "newprop");
} catch (JMSException e) {
e.printStackTrace();
}
contextMD.setRollbackOnly();
}
}
您在新版本中看到的行為是正確的。 相關更改是通過AMQ-7464進行的。 簡而言之,在消費期間對消息所做的更改不應反映在重新傳遞期間的消息中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.