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” />
</jms:listener-container>

…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:attributes>
<tx:method name=”*” rollback-for=”SpecialRuntimeException” />
</tx:attributes>
</tx:advice>

Update:

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:attributes>
<tx:method name=”*” rollback-for=”SpecialRuntimeException” propagation=”REQUIRES_NEW”/>
</tx:attributes>
</tx:advice>

Guess we’ll keep trying next time

Advertisements

, , ,

  1. Leave a comment

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s