spring-framework / org.springframework.jms.connection / ConnectionFactoryUtils

ConnectionFactoryUtils

abstract class ConnectionFactoryUtils

Helper class for managing a JMS javax.jms.ConnectionFactory, in particular for obtaining transactional JMS resources for a given ConnectionFactory.

Mainly for internal use within the framework. Used by org.springframework.jms.core.JmsTemplate as well as org.springframework.jms.listener.DefaultMessageListenerContainer.

Author
Juergen Hoeller

Since
2.0

See Also
SmartConnectionFactory

Constructors

<init>

ConnectionFactoryUtils()

Helper class for managing a JMS javax.jms.ConnectionFactory, in particular for obtaining transactional JMS resources for a given ConnectionFactory.

Mainly for internal use within the framework. Used by org.springframework.jms.core.JmsTemplate as well as org.springframework.jms.listener.DefaultMessageListenerContainer.

Functions

doGetTransactionalSession

open static fun doGetTransactionalSession(connectionFactory: ConnectionFactory, resourceFactory: ResourceFactory): Session

Obtain a JMS Session that is synchronized with the current transaction, if any.

This doGetTransactionalSession variant always starts the underlying JMS Connection, assuming that the Session will be used for receiving messages.

open static fun doGetTransactionalSession(connectionFactory: ConnectionFactory, resourceFactory: ResourceFactory, startConnection: Boolean): Session

Obtain a JMS Session that is synchronized with the current transaction, if any.

getTargetSession

open static fun getTargetSession(session: Session): Session

Return the innermost target Session of the given Session. If the given Session is a proxy, it will be unwrapped until a non-proxy Session is found. Otherwise, the passed-in Session will be returned as-is.

getTransactionalQueueSession

open static fun getTransactionalQueueSession(cf: QueueConnectionFactory, existingCon: QueueConnection, synchedLocalTransactionAllowed: Boolean): QueueSession

Obtain a JMS QueueSession that is synchronized with the current transaction, if any.

Mainly intended for use with the JMS 1.0.2 API.

getTransactionalSession

open static fun getTransactionalSession(cf: ConnectionFactory, existingCon: Connection, synchedLocalTransactionAllowed: Boolean): Session

Obtain a JMS Session that is synchronized with the current transaction, if any.

getTransactionalTopicSession

open static fun getTransactionalTopicSession(cf: TopicConnectionFactory, existingCon: TopicConnection, synchedLocalTransactionAllowed: Boolean): TopicSession

Obtain a JMS TopicSession that is synchronized with the current transaction, if any.

Mainly intended for use with the JMS 1.0.2 API.

isSessionTransactional

open static fun isSessionTransactional(session: Session, cf: ConnectionFactory): Boolean

Determine whether the given JMS Session is transactional, that is, bound to the current thread by Spring's transaction facilities.

releaseConnection

open static fun releaseConnection(con: Connection, cf: ConnectionFactory, started: Boolean): Unit

Release the given Connection, stopping it (if necessary) and eventually closing it.

Checks SmartConnectionFactory#shouldStop, if available. This is essentially a more sophisticated version of org.springframework.jms.support.JmsUtils#closeConnection.