XA transactions: how ’bout them rollbacks?

Last time we got something working.  To continue…

Ok, I changed my MessageListener to throw a RuntimeException when it receives a message.  Now when I send a message from the ActiveMQ console, I get a nice little stack trace on the JBoss console, but I can still send more messages (that is, Spring seems to recover from the exception and the MessageListener isn’t just gone after the exception).

The thing is though, after I throw the exception from the MessageListener, the message is still gone from the queue.  I expected it to roll back…

Are we in an XA transaction?

I’m not sure if I’m in an XA transaction or not.  I thought I was, because I have this in my Spring bean file:

<tx:jta-transaction-manager id=”transactionManager” />

<bean id=”jmsContainer” class=”org.springframework.jms.listener.DefaultMessageListenerContainer”>
<property name=”connectionFactory” ref=”queueConnectionFactory” />
<property name=”destination” ref=”destination” />
<property name=”messageListener” ref=”messageListener” />
<property name=”transactionManager” ref=”transactionManager” />
</bean>

…and these lines appear on the JBoss console:

12:24:38,579 INFO  [JtaTransactionManager] Using JTA UserTransaction: org.jboss.tm.usertx.client.ServerVMClientUserTransaction@1a6ac39
12:24:38,579 INFO  [JtaTransactionManager] Using JTA TransactionManager: com.arjuna.ats.jbossatx.jta.TransactionManagerDelegate@1604a9e

So I looked in the Spring manual Section 9.5.3 Rolling back, and it looks like we would use AOP to specify what types of exceptions should trigger a rollback.

We’ll tackle that next!

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