Redelivery of message fails after a rollback with Spring DMLC with cacheLevel=CACHE_NONE due to a bug in class : 'org.apache.activemq.ActiveMQMessageConsumer'. Redelivered messages are wrongly detected as duplicates. It fails to call 'rollbackDuplicates' on messages processed by consumer on rollback call on the consumer.
Sequence: ( See: http://fisheye1.atlassian.com/browse/springframework/spring/src/org/springframework/jms/listener/AbstractPollingMessageListenerContainer.java?r=1.14 )
- Spring creates a transaction
- Spring creates a JMS consumer
- Spring give message to Application MessageListener class
- Spring closes the consumer
- Spring try to commit
- Commit fails due to a RuntimeException thrown in Application MessageListener class
- Spring marks the message as RollbackOnly
- Spring rollbacks message
When ActiveMQ closes the consumer ( org.apache.activemq.ActiveMQMessageConsumer ), it clears 'deliveredMessages' list. But this list is needed in rollback method of ActiveMQMessageConsumer to rollback duplicates ! Then consumer cannot rollback duplicates on rollback if consumer is closed before rollback action.
The only way I found, is to not clear 'deliveredMessages' list on close. It seems, there is no side effect, since after a call to 'close' method, the consumer is not used anymore.