|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.transaction.support.AbstractPlatformTransactionManager org.springframework.jms.connection.JmsTransactionManager
PlatformTransactionManager implementation for a single JMS ConnectionFactory. Binds a JMS Connection/Session pair from the specified ConnectionFactory to the thread, potentially allowing for one thread session per connection factory.
This local strategy is an alternative to executing JMS operations within JTA transactions. Its advantage is that it is able to work in any environment, for example a standalone application or a test suite. It is not able to provide XA transactions, for example to share transactions with data access.
JmsTemplate will auto-detect such thread-bound connection/session pairs and automatically participate in them. There is currently no support for letting plain JMS code participate in such transactions.
This transaction strategy will typically be used in combination with SingleConnectionFactory, which uses a single JMS connection for all JMS access to save resources, typically in a standalone application. Each transaction will then use the same JMS Connection but its own JMS Session.
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.
JmsTemplate
,
SingleConnectionFactory
,
Serialized FormField Summary |
Fields inherited from class org.springframework.transaction.support.AbstractPlatformTransactionManager |
logger, SYNCHRONIZATION_ALWAYS, SYNCHRONIZATION_NEVER, SYNCHRONIZATION_ON_ACTUAL_TRANSACTION |
Constructor Summary | |
JmsTransactionManager()
Create a new JmsTransactionManager for bean-style usage. |
|
JmsTransactionManager(ConnectionFactory connectionFactory)
Create a new JmsTransactionManager, given a ConnectionFactory. |
Method Summary | |
void |
afterPropertiesSet()
Make sure the connection factory has been set. |
protected Connection |
createConnection()
Create a JMS Connection via this template's ConnectionFactory. |
protected Session |
createSession(Connection con)
Create a JMS Session for the given Connection. |
protected void |
doBegin(Object transaction,
TransactionDefinition definition)
Begin a new transaction with the given transaction definition. |
protected void |
doCleanupAfterCompletion(Object transaction)
Cleanup resources after transaction completion. |
protected void |
doCommit(DefaultTransactionStatus status)
Perform an actual commit on the given transaction. |
protected Object |
doGetTransaction()
Return a current transaction object, i.e. a JTA UserTransaction. |
protected void |
doResume(Object transaction,
Object suspendedResources)
Resume the resources of the current transaction. |
protected void |
doRollback(DefaultTransactionStatus status)
Perform an actual rollback on the given transaction. |
protected void |
doSetRollbackOnly(DefaultTransactionStatus status)
Set the given transaction rollback-only. |
protected Object |
doSuspend(Object transaction)
Suspend the resources of the current transaction. |
ConnectionFactory |
getConnectionFactory()
Return the JMS ConnectionFactory that this instance should manage transactions for. |
protected boolean |
isExistingTransaction(Object transaction)
Check if the given transaction object indicates an existing, i.e. already begun, transaction. |
void |
setConnectionFactory(ConnectionFactory connectionFactory)
Set the JMS ConnectionFactory that this instance should manage transactions for. |
Methods inherited from class org.springframework.transaction.support.AbstractPlatformTransactionManager |
commit, getTransaction, getTransactionSynchronization, isNestedTransactionAllowed, isRollbackOnCommitFailure, rollback, setNestedTransactionAllowed, setRollbackOnCommitFailure, setTransactionSynchronization, setTransactionSynchronizationName, useSavepointForNestedTransaction |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public JmsTransactionManager()
Note: The ConnectionFactory has to be set before using the instance. This constructor can be used to prepare a JmsTemplate 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(javax.jms.ConnectionFactory)
,
AbstractPlatformTransactionManager.setTransactionSynchronization(int)
public JmsTransactionManager(ConnectionFactory connectionFactory)
connectionFactory
- the ConnectionFactory to obtain connections fromMethod Detail |
public void setConnectionFactory(ConnectionFactory connectionFactory)
public ConnectionFactory getConnectionFactory()
public void afterPropertiesSet()
protected Connection createConnection() throws JMSException
This implementation uses JMS 1.1 API.
JMSException
- if thrown by JMS API methodsprotected Session createSession(Connection con) throws JMSException
This implementation uses JMS 1.1 API.
con
- the JMS Connection to create a Session for
JMSException
- if thrown by JMS API methodsprotected Object doGetTransaction()
AbstractPlatformTransactionManager
doGetTransaction
in class AbstractPlatformTransactionManager
protected boolean isExistingTransaction(Object transaction)
AbstractPlatformTransactionManager
isExistingTransaction
in class AbstractPlatformTransactionManager
transaction
- transaction object returned by doGetTransaction
protected void doBegin(Object transaction, TransactionDefinition definition)
AbstractPlatformTransactionManager
doBegin
in class AbstractPlatformTransactionManager
transaction
- transaction object returned by doGetTransactiondefinition
- TransactionDefinition instance, describing
propagation behavior, isolation level, timeout etc.protected Object doSuspend(Object transaction)
AbstractPlatformTransactionManager
doSuspend
in class AbstractPlatformTransactionManager
transaction
- transaction object returned by doGetTransaction
AbstractPlatformTransactionManager.doResume(java.lang.Object, java.lang.Object)
protected void doResume(Object transaction, Object suspendedResources)
AbstractPlatformTransactionManager
doResume
in class AbstractPlatformTransactionManager
transaction
- transaction object returned by doGetTransactionsuspendedResources
- the object that holds suspended resources,
as returned by doSuspendAbstractPlatformTransactionManager.doSuspend(java.lang.Object)
protected void doCommit(DefaultTransactionStatus status)
AbstractPlatformTransactionManager
doCommit
in class AbstractPlatformTransactionManager
status
- status representation of the transactionprotected void doRollback(DefaultTransactionStatus status)
AbstractPlatformTransactionManager
doRollback
in class AbstractPlatformTransactionManager
status
- status representation of the transactionprotected void doSetRollbackOnly(DefaultTransactionStatus status)
AbstractPlatformTransactionManager
doSetRollbackOnly
in class AbstractPlatformTransactionManager
status
- status representation of the transactionprotected void doCleanupAfterCompletion(Object transaction)
AbstractPlatformTransactionManager
Default implementation does nothing.
doCleanupAfterCompletion
in class AbstractPlatformTransactionManager
transaction
- transaction object returned by doGetTransaction
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |