Spring JMS消息重新传递不能按预期的方式运行CLIENT_ACKNOWLEDGE模式

时间:2016-12-01 21:07:09

标签: spring jms jndi ibm-mq spring-jms

我的环境:spring 4.1JBoss EAP 6.4IBM MQ 8.0

Listener抛出RuntimeException的情况下,不会重新传递邮件。

我在JmsConfig中有以下内容:

@Bean
DefaultMessageListenerContainer defaultMessageListenerContainer(QueueConnectionFactory connectionFactory, JndiDestinationResolver dr, MessageListener ml) {
    DefaultMessageListenerContainer mlc = new DefaultMessageListenerContainer();
    mlc.setConnectionFactory(connectionFactory);
    mlc.setMessageListener(ml);
    mlc.setDestinationName(jndiInQueue);
    mlc.setDestinationResolver(dr);
    mlc.setSessionTransacted(true);
    mlc.setSessionAcknowledgeMode(Session.CLIENT_ACKNOWLEDGE);
    return mlc;
}

如果我使用JmsTransactionManager并将其传递给上述方法并使用如下:

mlc.setTransactionManager(tm)

以下警告将写入日志:

It is not valid to commit a non-transacted session,行为相同,没有重新发送。

ConnectionFactory是通过JNDI获得的,我想知道通过jndi获取ConnectionFactory是否与此有关?

来自AbstractMessageListenerContainer Javadocs:

  

为了始终如一地安排任何容器变体的重新发送,请考虑" CLIENT_ACKNOWLEDGE"模式或 - 最好 - 设置" sessionTransacted"到"真"代替

SO上有一个similar question

0 个答案:

没有答案