|
Spring AMQP | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.springframework.transaction.support.AbstractPlatformTransactionManager
org.springframework.amqp.rabbit.transaction.RabbitTransactionManager
public class RabbitTransactionManager
PlatformTransactionManager implementation for a single Rabbit
ConnectionFactory. Binds a Rabbit Channel from the specified ConnectionFactory to the thread, potentially
allowing for one thread-bound channel per ConnectionFactory.
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
ConnectionFactoryUtils.getTransactionalResourceHolder(ConnectionFactory, boolean) instead of a standard
Connection.createChannel() call with subsequent Channel creation. Spring's RabbitTemplate will
autodetect a thread-bound Channel and automatically participate in it.
The use of 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 DataSourceTransactionManager,
which has stronger needs for synchronization.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class org.springframework.transaction.support.AbstractPlatformTransactionManager |
|---|
AbstractPlatformTransactionManager.SuspendedResourcesHolder |
| Field Summary |
|---|
| Fields inherited from class org.springframework.transaction.support.AbstractPlatformTransactionManager |
|---|
logger, SYNCHRONIZATION_ALWAYS, SYNCHRONIZATION_NEVER, SYNCHRONIZATION_ON_ACTUAL_TRANSACTION |
| Constructor Summary | |
|---|---|
RabbitTransactionManager()
Create a new RabbitTransactionManager for bean-style usage. |
|
RabbitTransactionManager(ConnectionFactory connectionFactory)
Create a new RabbitTransactionManager, given a ConnectionFactory. |
|
| Method Summary | |
|---|---|
void |
afterPropertiesSet()
Make sure the ConnectionFactory has been set. |
protected void |
doBegin(Object transaction,
TransactionDefinition definition)
|
protected void |
doCleanupAfterCompletion(Object transaction)
|
protected void |
doCommit(DefaultTransactionStatus status)
|
protected Object |
doGetTransaction()
|
protected void |
doResume(Object transaction,
Object suspendedResources)
|
protected void |
doRollback(DefaultTransactionStatus status)
|
protected void |
doSetRollbackOnly(DefaultTransactionStatus status)
|
protected Object |
doSuspend(Object transaction)
|
ConnectionFactory |
getConnectionFactory()
|
Object |
getResourceFactory()
|
protected boolean |
isExistingTransaction(Object transaction)
|
void |
setConnectionFactory(ConnectionFactory connectionFactory)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.springframework.transaction.PlatformTransactionManager |
|---|
commit, getTransaction, rollback |
| Constructor Detail |
|---|
public RabbitTransactionManager()
Note: The ConnectionFactory has to be set before using the instance. This constructor can be used to prepare a RabbitTemplate via a BeanFactory, typically setting the ConnectionFactory via setConnectionFactory.
Turns off transaction synchronization by default, as this manager might be used alongside a datastore-based Spring transaction manager like DataSourceTransactionManager, which has stronger needs for synchronization. Only one manager is allowed to drive synchronization at any point of time.
setConnectionFactory(org.springframework.amqp.rabbit.connection.ConnectionFactory),
AbstractPlatformTransactionManager.setTransactionSynchronization(int)public RabbitTransactionManager(ConnectionFactory connectionFactory)
connectionFactory - the ConnectionFactory to use| Method Detail |
|---|
public void setConnectionFactory(ConnectionFactory connectionFactory)
connectionFactory - the connectionFactory to setpublic ConnectionFactory getConnectionFactory()
public void afterPropertiesSet()
afterPropertiesSet in interface InitializingBeanpublic Object getResourceFactory()
getResourceFactory in interface ResourceTransactionManagerprotected Object doGetTransaction()
doGetTransaction in class AbstractPlatformTransactionManagerprotected boolean isExistingTransaction(Object transaction)
isExistingTransaction in class AbstractPlatformTransactionManager
protected void doBegin(Object transaction,
TransactionDefinition definition)
doBegin in class AbstractPlatformTransactionManagerprotected Object doSuspend(Object transaction)
doSuspend in class AbstractPlatformTransactionManager
protected void doResume(Object transaction,
Object suspendedResources)
doResume in class AbstractPlatformTransactionManagerprotected void doCommit(DefaultTransactionStatus status)
doCommit in class AbstractPlatformTransactionManagerprotected void doRollback(DefaultTransactionStatus status)
doRollback in class AbstractPlatformTransactionManagerprotected void doSetRollbackOnly(DefaultTransactionStatus status)
doSetRollbackOnly in class AbstractPlatformTransactionManagerprotected void doCleanupAfterCompletion(Object transaction)
doCleanupAfterCompletion in class AbstractPlatformTransactionManager
|
Spring AMQP | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||