我的环境:spring 4.1
,JBoss EAP 6.4
,IBM 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。