org.springframework.jms.connection
public class: JmsTransactionManager102 [javadoc |
source]
java.lang.Object
org.springframework.transaction.support.AbstractPlatformTransactionManager
org.springframework.jms.connection.JmsTransactionManager
org.springframework.jms.connection.JmsTransactionManager102
All Implemented Interfaces:
InitializingBean, ResourceTransactionManager, PlatformTransactionManager, Serializable
A subclass of
JmsTransactionManager for the JMS 1.0.2 specification,
not relying on JMS 1.1 methods like JmsTransactionManager itself.
This class can be used for JMS 1.0.2 providers, offering the same API as
JmsTransactionManager does for JMS 1.1 providers.
You need to set the "pubSubDomain" property ,
since this class will always explicitly differentiate between a
javax.jms.QueueConnection and a javax.jms.TopicConnection .
| Constructor: |
public JmsTransactionManager102() {
super();
}
Create a new JmsTransactionManager102 for bean-style usage.
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. |
public JmsTransactionManager102(ConnectionFactory connectionFactory,
boolean pubSubDomain) {
setConnectionFactory(connectionFactory);
this.pubSubDomain = pubSubDomain;
afterPropertiesSet();
}
Create a new JmsTransactionManager102, given a ConnectionFactory. Parameters:
connectionFactory - the ConnectionFactory to manage transactions for
pubSubDomain - whether the Publish/Subscribe domain (Topics) or
Point-to-Point domain (Queues) should be used
Also see:
- setPubSubDomain
|
| Methods from org.springframework.jms.connection.JmsTransactionManager: |
|---|
|
afterPropertiesSet, createConnection, createSession, doBegin, doCleanupAfterCompletion, doCommit, doGetTransaction, doResume, doRollback, doSetRollbackOnly, doSuspend, getConnectionFactory, getResourceFactory, isExistingTransaction, setConnectionFactory |
| Methods from org.springframework.transaction.support.AbstractPlatformTransactionManager: |
|---|
|
commit, determineTimeout, doBegin, doCleanupAfterCompletion, doCommit, doGetTransaction, doResume, doRollback, doSetRollbackOnly, doSuspend, getDefaultTimeout, getTransaction, getTransactionSynchronization, invokeAfterCompletion, isExistingTransaction, isFailEarlyOnGlobalRollbackOnly, isGlobalRollbackOnParticipationFailure, isNestedTransactionAllowed, isRollbackOnCommitFailure, isValidateExistingTransaction, newTransactionStatus, prepareForCommit, registerAfterCompletionWithExistingTransaction, resume, rollback, setDefaultTimeout, setFailEarlyOnGlobalRollbackOnly, setGlobalRollbackOnParticipationFailure, setNestedTransactionAllowed, setRollbackOnCommitFailure, setTransactionSynchronization, setTransactionSynchronizationName, setValidateExistingTransaction, shouldCommitOnGlobalRollbackOnly, suspend, triggerBeforeCommit, triggerBeforeCompletion, useSavepointForNestedTransaction |
| Method from org.springframework.jms.connection.JmsTransactionManager102 Detail: |
public void afterPropertiesSet() {
super.afterPropertiesSet();
// Make sure that the ConnectionFactory passed is consistent.
// Some provider implementations of the ConnectionFactory interface
// implement both domain interfaces under the cover, so just check if
// the selected domain is consistent with the type of connection factory.
if (isPubSubDomain()) {
if (!(getConnectionFactory() instanceof TopicConnectionFactory)) {
throw new IllegalArgumentException(
"Specified a Spring JMS 1.0.2 transaction manager for topics " +
"but did not supply an instance of TopicConnectionFactory");
}
}
else {
if (!(getConnectionFactory() instanceof QueueConnectionFactory)) {
throw new IllegalArgumentException(
"Specified a Spring JMS 1.0.2 transaction manager for queues " +
"but did not supply an instance of QueueConnectionFactory");
}
}
}
In addition to checking if the connection factory is set, make sure
that the supplied connection factory is of the appropriate type for
the specified destination type: QueueConnectionFactory for queues,
and TopicConnectionFactory for topics. |
protected Connection createConnection() throws JMSException {
if (isPubSubDomain()) {
return ((TopicConnectionFactory) getConnectionFactory()).createTopicConnection();
}
else {
return ((QueueConnectionFactory) getConnectionFactory()).createQueueConnection();
}
}
This implementation overrides the superclass method to use JMS 1.0.2 API. |
protected Session createSession(Connection con) throws JMSException {
if (isPubSubDomain()) {
return ((TopicConnection) con).createTopicSession(true, Session.AUTO_ACKNOWLEDGE);
}
else {
return ((QueueConnection) con).createQueueSession(true, Session.AUTO_ACKNOWLEDGE);
}
}
This implementation overrides the superclass method to use JMS 1.0.2 API. |
public boolean isPubSubDomain() {
return this.pubSubDomain;
}
Return whether the Publish/Subscribe domain (Topics) is used.
Otherwise, the Point-to-Point domain (Queues) is used. |
public void setPubSubDomain(boolean pubSubDomain) {
this.pubSubDomain = pubSubDomain;
}
|