Results 1 to 3 of 3

Thread: Jms and database transaction Manager with DefaultMessageListnerContainer

  1. #1
    Join Date
    Oct 2012
    Posts
    2

    Default Jms and database transaction Manager with DefaultMessageListnerContainer

    Hi,

    I am using DefaultMessageListnerContainer with sessionTransacted=true and also jdbc transaction manager but jms messages are committed first and picked up by internal queue before database commit. I am not using annotation based transaction. Below is the config i am using,

    Code:
    <bean id="jmsContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
    		<property name="connectionFactory" ref="connectionFactory" />
    		<property name="destination" ref="destinationQueue" /> 
    		<property name="messageListener" ref="messageListner" /> 		
     		<property name="taskExecutor" ref="taskExecutor" />
     		<property name="sessionTransacted" value="true" /> 
     		<property name="transactionManager" ref="txManager" /> 
     		<property name="cacheLevel" value="1"/>
     		<property name="autoStartup" value="true" />
    	</bean>
    Code:
    <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    	  <property name="dataSource" ref="dataSource"/>
    	</bean>
    All other test cases are working fine like redelivery of message in case of database failure or internal queue write failure but because jms commit is happening prior to database commit, internal queue not able to find message in database to process. Sometime in second retry it works fine but there are times when internal not able able to find message in database even after 3-4 retry.

    Is there anyway to synchronize jms commit with jdbc commit to get rid of this issue. I do not want jms commit before database commit because in that case for any reason if application fails to write to internal queue, i can not rollback database changes.

    So is there any way to make jms commit and database commit at the same time?
    Last edited by Emly; Oct 26th, 2012 at 03:56 PM.

  2. #2
    Join Date
    Oct 2005
    Location
    Boston, MA
    Posts
    2,853

    Default

    I recommend reading this article by Dave Syer:
    http://www.javaworld.com/javaworld/j...nsactions.html

  3. #3
    Join Date
    Oct 2012
    Posts
    2

    Default

    I did go through Dave Syer article but could not find any solution to the issue i have as i can not have duplicate messages and also cant use JTA transactions. I am using WAS MQ if that helps. Am i missing something?
    Last edited by Emly; Oct 29th, 2012 at 04:18 PM.

Posting Permissions

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