user3504187
user3504187

Reputation: 83

How to make the flow transactional?

I am using a JMSTrnsactionManager which is able to read a message from a Queue and persist DB and then post the message to a Queue/Topic. when there is a failure in any of the gateays/ adapters I want to rollback the entire transaction and also rollback the data from DB. I am using Spring Integration framework with Message-driven-channel-adapter for reading from the queue and outbound-gateways for persisting to DB and outbound-adapters to post to topic. Datasource used is CombopooledDataSource. How to execute all of the above in a single transaction?

Upvotes: 0

Views: 700

Answers (1)

Gary Russell
Gary Russell

Reputation: 174544

You should not use a JmsTransactionManager on the inbound adapter - if you wish to synchronize the DB transaction (ala Best Effort 1PC in the article I pointed you to in your other question), you should add the JDBC Transaction manager to the message driven adapter. You need to also set acknowledge="transacted" on the adapter.

The outbound JMS adapter will automatically use the same transacted session on which the message is received.

Adding the JDBC transaction manager to the message driven adapter will synchronize the DB transaction with the JMS transaction (commit it immediately before the JMS transaction).

Upvotes: 1

Related Questions