Simple JMS transaction rollbacks work…

Last time, I thought I had AOP transaction advice in place, but I still was not seeing the rollbacks I thought I should. This time, we try simple JMS local transactions to see if they work, to have another data point…

If I change my DefaultMessageListenerContainer bean to remove the external JTA transaction manager reference and replace it with native JMS transactions like so:

<jms:listener-container acknowledge=”transacted” connection-factory=”queueConnectionFactory”>
<jms:listener destination=”gloriousTest.Queue” ref=”messageListener” />

…then I can throw an unchecked exception and it will rollback the receive of the message.  It then receives several times, until it goes to the dead letter queue.  However, it doesn’t seem to pay attention to my setting that is supposed to only roll back my SpecialRuntimeExceptions, not all RuntimeExceptions (unless I need a no-rollback-for attribute in my tx:advice):

<tx:advice id=”txAdvice” transaction-manager=”transactionManager”>
<tx:method name=”*” rollback-for=”SpecialRuntimeException” />


Back to a JTA transaction manager, adding the propagation=”REQUIRES_NEW” attribute didn’t help either (still no rollback when my messagelistener throws a SpecialRuntimeException):

<tx:advice id=”txAdvice” transaction-manager=”transactionManager”>
<tx:method name=”*” rollback-for=”SpecialRuntimeException” propagation=”REQUIRES_NEW”/>

Guess we’ll keep trying next time

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.