问题
I have the following pattern

I have two kinds of databases. One is a internal database where it saves data from 5 json datas from http inbound gateways. The Other is a external database where it saves final refiend data from 5 jsons saved tables.
The Process is like the followings.
One Transaction
① Each message is saved to each table and return status to the client where it sends data.
Second Transaction
② If 5 kinds of datas are completed to receive, it activate one service activator where queries 5 tables and make 3 kinds of refined data that will save in external database.
③ The next connected channel type is a publish-subscribe channel.
④ There are 3 kinds of subscribe channel to deliver each jdbc-outbound-gateway for saving data to external database. (There is a rowmapper process to handle saving multiple rows)
How can I set the transaction for being guaranteed? Please let me know elaborately.
回答1:
Add a QueueChannel
somewhere upstream (i.e. before the pub sub channel for tx2) and use a <transactional/>
poller to start the transaction.
Alternatively, insert a transactional gateway...
<int:service-activator ... ref="txGw" />
<int:gateway ... service-interface="TX" />
public interface TX {
@Transactional
Message<?> exchange(Message<?> m);
}
You'll need <tx:annotation-driven />
to enable transactions in the second case.
来源:https://stackoverflow.com/questions/26419602/spring-integration-how-to-guarantee-the-transaction-two-more-jdbc-outbound-gat