Results 1 to 2 of 2

Thread: JPA - JMS Transaction

  1. #1
    Join Date
    Jun 2008
    Posts
    7

    Default JPA - JMS Transaction

    Hi,

    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>
    <bean id="myConnectionFactoryBean" class="org.springframework.jndi.JndiObjectFactoryB ean">
    <property name="jndiTemplate">
    <ref bean="myJndiTemplate" />
    </property>
    <property name="jndiName">
    <value>ConnectionFactory</value>
    </property>
    </bean>


    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. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,624

    Default

    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.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •