The Spring Framework

org.springframework.jms.connection
Class ConnectionFactoryUtils

java.lang.Object
  extended by org.springframework.jms.connection.ConnectionFactoryUtils

public abstract class ConnectionFactoryUtils
extends Object

Helper class for obtaining transactional JMS resources for a given ConnectionFactory.

Since:
2.0
Author:
Juergen Hoeller

Nested Class Summary
static interface ConnectionFactoryUtils.ResourceFactory
          Callback interface for resource creation.
 
Constructor Summary
ConnectionFactoryUtils()
           
 
Method Summary
static Session doGetTransactionalSession(Object resourceKey, ConnectionFactoryUtils.ResourceFactory resourceFactory)
          Obtain a JMS Session that is synchronized with the current transaction, if any.
static QueueSession getTransactionalQueueSession(QueueConnectionFactory cf, QueueConnection existingCon, boolean synchedLocalTransactionAllowed)
          Obtain a JMS QueueSession that is synchronized with the current transaction, if any.
static Session getTransactionalSession(ConnectionFactory cf, Connection existingCon, boolean synchedLocalTransactionAllowed)
          Obtain a JMS Session that is synchronized with the current transaction, if any.
static TopicSession getTransactionalTopicSession(TopicConnectionFactory cf, TopicConnection existingCon, boolean synchedLocalTransactionAllowed)
          Obtain a JMS TopicSession that is synchronized with the current transaction, if any.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConnectionFactoryUtils

public ConnectionFactoryUtils()
Method Detail

getTransactionalSession

public static Session getTransactionalSession(ConnectionFactory cf,
                                              Connection existingCon,
                                              boolean synchedLocalTransactionAllowed)
                                       throws JMSException
Obtain a JMS Session that is synchronized with the current transaction, if any.

Parameters:
cf - the ConnectionFactory to obtain a Session for
existingCon - the existing JMS Connection to obtain a Session for (may be null)
synchedLocalTransactionAllowed - whether to allow for a local JMS transaction that is synchronized with a Spring-managed transaction (where the main transaction might be a JDBC-based one for a specific DataSource, for example), with the JMS transaction committing right after the main transaction. If not allowed, the given ConnectionFactory needs to handle transaction enlistment underneath the covers.
Returns:
the transactional Session, or null if none found
Throws:
JMSException - in case of JMS failure

getTransactionalQueueSession

public static QueueSession getTransactionalQueueSession(QueueConnectionFactory cf,
                                                        QueueConnection existingCon,
                                                        boolean synchedLocalTransactionAllowed)
                                                 throws JMSException
Obtain a JMS QueueSession that is synchronized with the current transaction, if any.

Mainly intended for use with the JMS 1.0.2 API.

Parameters:
cf - the ConnectionFactory to obtain a Session for
existingCon - the existing JMS Connection to obtain a Session for (may be null)
synchedLocalTransactionAllowed - whether to allow for a local JMS transaction that is synchronized with a Spring-managed transaction (where the main transaction might be a JDBC-based one for a specific DataSource, for example), with the JMS transaction committing right after the main transaction. If not allowed, the given ConnectionFactory needs to handle transaction enlistment underneath the covers.
Returns:
the transactional Session, or null if none found
Throws:
JMSException - in case of JMS failure

getTransactionalTopicSession

public static TopicSession getTransactionalTopicSession(TopicConnectionFactory cf,
                                                        TopicConnection existingCon,
                                                        boolean synchedLocalTransactionAllowed)
                                                 throws JMSException
Obtain a JMS TopicSession that is synchronized with the current transaction, if any.

Mainly intended for use with the JMS 1.0.2 API.

Parameters:
cf - the ConnectionFactory to obtain a Session for
existingCon - the existing JMS Connection to obtain a Session for (may be null)
synchedLocalTransactionAllowed - whether to allow for a local JMS transaction that is synchronized with a Spring-managed transaction (where the main transaction might be a JDBC-based one for a specific DataSource, for example), with the JMS transaction committing right after the main transaction. If not allowed, the given ConnectionFactory needs to handle transaction enlistment underneath the covers.
Returns:
the transactional Session, or null if none found
Throws:
JMSException - in case of JMS failure

doGetTransactionalSession

public static Session doGetTransactionalSession(Object resourceKey,
                                                ConnectionFactoryUtils.ResourceFactory resourceFactory)
                                         throws JMSException
Obtain a JMS Session that is synchronized with the current transaction, if any.

Parameters:
resourceKey - the TransactionSynchronizationManager key to bind to (usually the ConnectionFactory)
resourceFactory - the ResourceFactory to use for extracting or creating JMS resources
Returns:
the transactional Session, or null if none found
Throws:
JMSException - in case of JMS failure

The Spring Framework

Copyright © 2002-2006 The Spring Framework.