Announcement Announcement Module
No announcement yet.
Jms and database transaction Manager with DefaultMessageListnerContainer Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Jms and database transaction Manager with DefaultMessageListnerContainer


    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,

    <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 id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    	  <property name="dataSource" ref="dataSource"/>
    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, 04:56 PM.

  • #2
    I recommend reading this article by Dave Syer:


    • #3
      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, 05:18 PM.