1
votes

I have a spring integration application and I am using message driven channel adapter for consuming the messages. This is the definition of the adapter -

<jms:message-driven-channel-adapter id="messageAdapter" destination="inQueue"
                                    connection-factory="connectionFactory"
                                    error-channel="errorChannel"
                                    concurrent-consumers="${consumer.concurrent-consumers}"
                                    acknowledge="transacted"
                                    transaction-manager="transactionManager"
                                    channel="channel"
                                    auto-startup="true"
                                    receive-timeout="50000"/>

So this message goes to my core channel and then goes through a series of service activators. In between if there is a error than this message is moved to errorChannel where I handle the errors and decide on what needs to be done with this message. For one scenario I want the message to not rollback to the queue, is it possible? I am using 'transacted' in my adapter definition so I am not sure how to drive this behaviour. Any help is greatly appreciated!

1

1 Answers

0
votes

You don't describe what the transactionManager bean is. If it's a JmsTransactionManager, remove it and the container will just use local transactions.

Then, the transaction will only roll back if the flow on the error-channel throws an exception. If that error flow exits normally ("consuming" the error), the transaction will not roll back.

If it's some other transaction manager (e.g. JDBC) then remove it and start the JDBC transaction later in the flow (i.e. don't synchronize the JMS and JDBC transactions; again using a local JMS transaction).