May 19th, 2009, 09:26 AM
JPA - JMS Transaction
I've following requirement:
1) create/update a record in database (from service impl pojo).
2) once record is created/updated, send jms message to queue1, queue2 and queue3 (from the same service impl pojo)
3) if sending to any of these queues fails, roll back queues(if msg dropped on any) and the db transaction.
I'm using Spring JmsTemplate for sending messages and i've set sessionTransacted=true. for three different queue i've three different JmsTemplate and one spring SingleConnectionFactory (see following).
<property name="targetConnectionFactory" ref="myConnectionFactoryBean" />
<bean id="myConnectionFactoryBean" class="org.springframework.jndi.JndiObjectFactoryB ean">
<ref bean="myJndiTemplate" />
I've define point cut using aop at the method level of the service impl pojo.
To test this scenario, i am bringing down queue2 and executing the method of the service impl pojo. Here, the db is not rolling back, but the message in queue1 is rolled back.
How can i achieve the rollback for both the db and jms queues? I want to achieve this primarily without JTA(if possible). Any solutions will be highly appreciated. :-)
May 19th, 2009, 12:27 PM
Well either use JTA (although you don't want it but you still have multiple transactions) or you will have to write some logic yourself to compensate/rollback the transaction. Juergen did a presentations about transactions and did some presentation on something similair as you want, the slides are here.