Description
While using DefaultMessageListenerContainer the JMSConsumer is not properly rolling back transactions.
In AbstractMessageListenerContainer in doExecuteListener(...). it invokes rollbackIfNecessary(...)
The condition in rollbackIfNeccessary(): "session.getTransacted() && isSessionLocallyTransacted(session)" is evaluating to false at runtime so the rollback is not executed.
isSessionsLocallyTransacted(...) was evaluated to false because JmsAccessor.sessionTransacted field is set to false;
The reason is due to JmsConsumerEndpoint.createDefaultMessageListenerContainer(...) method implementation:
else if (TRANSACTED_JMS.equals(transacted)) { if (jms102) { cont.setTransactionManager(new JmsTransactionManager102(getConnectionFactory(), isPubSubDomain())); } else { cont.setTransactionManager(new JmsTransactionManager(getConnectionFactory())); } }
Needs to be
} else if (TRANSACTED_JMS.equals(transacted)) { cont.setSessionTransacted(true); if (jms102) { cont.setTransactionManager(new JmsTransactionManager102(getConnectionFactory(), isPubSubDomain())); } else { cont.setTransactionManager(new JmsTransactionManager(getConnectionFactory())); } }