Announcement Announcement Module
No announcement yet.
Transaction handling while using message driven channel adapter & service activator Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Transaction handling while using message driven channel adapter & service activator

    I am working on a POC which does the following

    1. Uses a message driven channel adapter to recieve message in a transaction
    2. Calls the Service Activator which uses a handler to insert the message recieved from the adapter to DB and also post message to outbound channel.

    Now, if the DB insert of the message fails i want the JMS message returned back to the queue so that it can be re-tried later.

    With my below configuration it doesnt seems to work.(i.e. even if there is a failure while inserting into the database the message is removed from the queue.

    Any pointers or sample configuration would be helpful.

    <integration:channel id="jmsInChannel">
    <int-jms:message-driven-channel-adapter id="jmsIn" transaction-manager="transactionManager" connection-factory="sConnectionFactory" 
    		destination-name="emsQueue" acknowledge="client" channel="jmsInChannel" extract-payload="false"/>
    <integration:service-activator input-channel="jmsInChannel" output-channel="fileNamesChannel" ref="handler" method="process" />
    	<bean id="handler" class="com.irebalpoc.integration.MessageProcessor">
    		<property name="jobHashTable" ref="jobsMapping" />

  • #2
    You have acknowledge="client". Try changing that to acknowledge="transactional".


    • #3
      I had tried that initially. It did not work, got the same issue. Let me know if any more info is required.


      • #4
        You can't use a <queue/> channel because you need the database operation to occur on the same thread as the JMS operation.

        set acknowledge to 'transacted'. You also don't need to specify the transaction manager (unless you are running in a J2EE container).

        Also, read for implications of using synchronized transactions rather than full XA.


        • #5
          I did the change as per your suggesting and its working. Now i want to set retry time limit so that the retry happens say every 2 minutes. is there any way to do that? i tried recovery-interval="20000", but it doesnt work.


          • #6
            Recovery interval is for recovering connections; it has nothing to do with message delivery; there is no way for a JMS consumer to instruct the broker to delay redelivery.