繁体   English   中英

JMS setRollbackOnly - 不一致的行为

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM