Reputation: 47
My DefaultMessageListernerFactory bean looks like
@Bean
public JmsListenerContainerFactory<?> jmsListenerContainerFactory(ConnectionFactory connectionFactory,
DefaultJmsListenerContainerFactoryConfigurer configurer) {
DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
factory.setSessionTransacted(false);
factory.setSessionAcknowledgeMode(Session.AUTO_ACKNOWLEDGE);
factory.setErrorHandler(new DefaultJMSErrorHandler());
configurer.configure(factory, connectionFactory);
return factory;
}
Using @JmsListener and when my application throws an exception -- I expected my messsage to NOT be requed back but I notice that it is. I thought sessionTransaction(false) should not exhibit this behavior.
I noticed my transaction logs saying this
2019-09-20 14:22:42.609 DEBUG 17252 --- [enerContainer-1] o.s.j.l.DefaultMessageListenerContainer : Initiating transaction rollback on application exception
During debug, I noticed that the DefaultMessageListner has sessionTransacted to be true. It also creates a JMS session with a mode(0) -- SESSION_TRANSACTED
I am obviously missing something.
Can someone tell me what I am missing here ?
FYI -- I am using IBM MQ
Upvotes: 1
Views: 987
Reputation: 174494
factory.setSessionTransacted(false);
You need to do that AFTER configurer.configure(factory, connectionFactory);
, which has this code...
if (this.transactionManager != null) {
factory.setTransactionManager(this.transactionManager);
}
else {
factory.setSessionTransacted(true);
}
Upvotes: 2