Announcement Announcement Module
No announcement yet.
JPA - JMS Transaction Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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).

    <bean id="myConnectionFactory"
    class="org.springframework.jms.connection.SingleCo nnectionFactory">
    <property name="targetConnectionFactory" ref="myConnectionFactoryBean" />
    <bean id="myConnectionFactoryBean" class="org.springframework.jndi.JndiObjectFactoryB ean">
    <property name="jndiTemplate">
    <ref bean="myJndiTemplate" />
    <property name="jndiName">

    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. :-)

  • #2
    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.