Announcement Announcement Module
Collapse
No announcement yet.
Standalone java transaction management Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Standalone java transaction management

    Hi,
    I am using DMLC for receiving messages in a standalone application. how to synchronize my database transaction and JMS transaction?

    Below is the context xml
    Code:
    	<bean id="msgListenerContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer" 
    	   p:connectionFactory-ref="jmsQueueConnectionFactory"
    	   p:destination-ref="destination"
    	   p:messageListener-ref="messageListener"
    	   p:concurrentConsumers="5"
    	   p:maxConcurrentConsumers="10"
    	   p:receiveTimeout="2000"
    	   p:idleTaskExecutionLimit="10"
    	   p:idleConsumerLimit="5" 
    	   p:cacheLevelName="CACHE_CONSUMER" 
    	   p:taskExecutor-ref="listnerTaskExecutor"/>
    Please provide sample code. It will be greatly helpful.

  • #2
    Simply add the JdbcTransactionManager to the DMLC and it will automatically synchronize the JDBC transaction with the JMS transaction and commit the JDBC transaction immediately before the JMS commit.

    See http://www.javaworld.com/javaworld/j...nsactions.html and in particular Best Efforts 1PC pattern.
    Last edited by Gary Russell; May 30th, 2013, 08:26 AM.

    Comment


    • #3
      Question 1 :
      If i want to start JMS transaction first and then jdbc followed by jdbc commit and jms commit. how to do it?

      Question 2 :
      For standalone java app, which API best supports XA transaction? Or
      Is there a way to do XA with Spring jms itself?

      Comment


      • #4
        #1 - sorry. that was a typo - the JDBC transaction *is* committed right before the JMS transaction

        #2 - no; Spring does not provide an XA transaction manager you need to use a library such as Atomikos

        Comment


        • #5
          Thanks Gary for your quick and prompt responses.

          Using TIBCO EMS server. Need to implement vendor specific acknowledgement mode using spring configuration. i.e., EXPLICIT_CLIENT_ACKNOWLEDGE available in TIBCO. Kindly help how this can be used in the spring context xml..

          Comment


          • #6
            You could probably subclass the DMLC - override the createSession() method to set that option, and override isClientAcknowledge() to return true so the container will ack the message.

            Comment


            • #7
              Thanks Gary.

              Comment

              Working...
              X