This local strategy is an alternative to executing Rabbit operations within, and synchronized with, external transactions. This strategy is not able to provide XA transactions, for example in order to share transactions between messaging and database access.
Application code is required to retrieve the transactional Rabbit resources via {@link ConnectionFactoryUtils#getTransactionalResourceHolder(ConnectionFactory,boolean)} instead of a standard{@link Connection#createChannel()} call with subsequent Channel creation. Spring's {@link RabbitTemplate} willautodetect a thread-bound Channel and automatically participate in it.
The use of {@link CachingConnectionFactory} as a target for this transaction manager is strongly recommended.CachingConnectionFactory uses a single Rabbit Connection for all Rabbit access in order to avoid the overhead of repeated Connection creation, as well as maintaining a cache of Channels. Each transaction will then share the same Rabbit Connection, while still using its own individual Rabbit Channel.
Transaction synchronization is turned off by default, as this manager might be used alongside a datastore-based Spring transaction manager such as the JDBC org.springframework.jdbc.datasource.DataSourceTransactionManager, which has stronger needs for synchronization. @author Dave Syer
|
|