[英]JMS setRollbackOnly - inconsistent behaviour
Please have a look at the following Message Driver Bean.请查看以下消息驱动程序 Bean。 The message comes in, we call clearProperties()
on it to unlock and be able set some other properties on it.消息进来后,我们对其调用clearProperties()
以解锁并能够在其上设置一些其他属性。 At the end we call setRollbackOnly()
on the MessageDrivenContext
so that the message will be re-delivered.最后,我们在MessageDrivenContext
上调用setRollbackOnly()
以便重新传递消息。
We use ActiveMQ as a message broker with JBoss and the corresponding activemq-rar.rar
resource adapter.我们使用 ActiveMQ 作为消息代理,带有 JBoss 和相应的activemq-rar.rar
资源适配器。 There is a difference although between recent and new releases on how this resource adapter behaves regarding the code segment below.尽管最近和新版本之间关于此资源适配器关于下面代码段的行为方式存在差异。 Until version "5.11.0.redhat-630446" of the resource adapter, the property("newprop")
we set in the onMessage
method appeared in the message that has been re-delivered.直到版本“5.11.0.redhat-630446”的资源适配器,我们在onMessage
方法中设置的property("newprop")
出现在重新投递的消息中。 Since version "5.11.0.redhat-630475" the clearProperties()
and setObjectProperty()
method has no effect on the re-delivered message, so it falls in the onMessage
method with the same properties as the original 1st message.从版本“5.11.0.redhat-630475”开始, clearProperties()
和setObjectProperty()
方法对重新发送的消息没有影响,因此它属于onMessage
方法,具有与原始第一条消息相同的属性。
I wonder which is the right behaviour?我想知道哪种行为是正确的?
@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();
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.