jakarta.jms.ConnectionFactory , in particular
for obtaining transactional JMS resources for a given ConnectionFactory.
Mainly for internal use within the framework. Used by
org. as well as
org..
SmartConnectionFactory
| Modifier and Type | Class and Description |
|---|---|
| private static class | ConnectionFactoryUtils.
Callback for resource cleanup at the end of a non-native JMS transaction (e.g. when participating in a JtaTransactionManager transaction). |
| public static interface | ConnectionFactoryUtils.
Callback interface for resource creation. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public static Session | Returns: the transactional Session, ornull if none foundthe JMS ConnectionFactory to bind for
(used as TransactionSynchronizationManager key) connectionFactory, ConnectionFactoryUtils.the ResourceFactory to use for extracting or creating
JMS resources resourceFactoryObtain a JMS Session that is synchronized with the current transaction, if any. |
| public static Session | Returns: the transactional Session, ornull if none foundthe JMS ConnectionFactory to bind for
(used as TransactionSynchronizationManager key) connectionFactory, ConnectionFactoryUtils.the ResourceFactory to use for extracting or creating
JMS resources resourceFactory,whether the underlying JMS Connection approach should be
started in order to allow for receiving messages. Note that a reused Connection
may already have been started before, even if this flag is startConnection)false.Obtain a JMS Session that is synchronized with the current transaction, if any. |
| public static Session | Returns: the innermost target Session, or the passed-in one if no proxythe Session proxy to unwrap session)Return the innermost target Session of the given Session. |
| public static QueueSession | Returns: the transactional Session, ornull if none foundthe ConnectionFactory to obtain a Session for cf, final QueueConnection the existing JMS Connection to obtain a Session for
(may be existingCon, final boolean null)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. synchedLocalTransactionAllowed)Obtain a JMS QueueSession that is synchronized with the current transaction, if any. |
| public static Session | Returns: the transactional Session, ornull if none foundthe ConnectionFactory to obtain a Session for cf, final Connection the existing JMS Connection to obtain a Session for
(may be existingCon, final boolean null)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. synchedLocalTransactionAllowed)Obtain a JMS Session that is synchronized with the current transaction, if any. |
| public static TopicSession | Returns: the transactional Session, ornull if none foundthe ConnectionFactory to obtain a Session for cf, final TopicConnection the existing JMS Connection to obtain a Session for
(may be existingCon, final boolean null)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. synchedLocalTransactionAllowed)Obtain a JMS TopicSession that is synchronized with the current transaction, if any. |
| public static boolean | Returns: whether the Session is transactionalthe JMS Session to check session, ConnectionFactory the JMS ConnectionFactory that the Session originated from cf)Determine whether the given JMS Session is transactional, that is, bound to the current thread by Spring's transaction facilities. |
| public static void | releaseConnection(Connection
the Connection to release
(if this is con, ConnectionFactory null, the call will be ignored)the ConnectionFactory that the Connection was obtained from
(may be cf, boolean null)whether the Connection might have been started by the application started)Release the given Connection, stopping it (if necessary) and eventually closing it. |
| logger | back to summary |
|---|---|
| private static final Log logger | |
| ConnectionFactoryUtils | back to summary |
|---|---|
| public ConnectionFactoryUtils() | |
| doGetTransactionalSession | back to summary |
|---|---|
| public static Session doGetTransactionalSession(ConnectionFactory connectionFactory, ConnectionFactoryUtils. Obtain a JMS Session that is synchronized with the current transaction, if any. This
| |
| doGetTransactionalSession | back to summary |
|---|---|
| public static Session doGetTransactionalSession(ConnectionFactory connectionFactory, ConnectionFactoryUtils. Obtain a JMS Session that is synchronized with the current transaction, if any.
| |
| getTargetSession | back to summary |
|---|---|
| public static Session getTargetSession(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 | back to summary |
|---|---|
| public static QueueSession getTransactionalQueueSession(final QueueConnectionFactory cf, final QueueConnection existingCon, final 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.
| |
| getTransactionalSession | back to summary |
|---|---|
| public static Session getTransactionalSession(final ConnectionFactory cf, final Connection existingCon, final boolean synchedLocalTransactionAllowed) throws JMSException Obtain a JMS Session that is synchronized with the current transaction, if any.
| |
| getTransactionalTopicSession | back to summary |
|---|---|
| public static TopicSession getTransactionalTopicSession(final TopicConnectionFactory cf, final TopicConnection existingCon, final 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.
| |
| isSessionTransactional | back to summary |
|---|---|
| public static boolean isSessionTransactional(Session session, ConnectionFactory cf) Determine whether the given JMS Session is transactional, that is, bound to the current thread by Spring's transaction facilities.
| |
| releaseConnection | back to summary |
|---|---|
| public static void releaseConnection(Connection con, ConnectionFactory cf, boolean started) Release the given Connection, stopping it (if necessary) and eventually closing it. Checks
| |
| Modifier and Type | Field and Description |
|---|---|
| private boolean | |
| private final boolean |
| Access | Constructor and Description |
|---|---|
| public | JmsResourceSynchronization(JmsResourceHolder resourceHolder, Object resourceKey, boolean transacted)
|
| Modifier and Type | Method and Description |
|---|---|
| public void | afterCompletion(int
completion status according to the status)STATUS_* constantsOverrides org. Overrides default org. Invoked after transaction commit/rollback. |
| protected void | processResourceAfterCommit(JmsResourceHolder
the resource holder to process resourceHolder)Overrides org. After-commit callback for the given resource holder. |
| protected void | releaseResource(JmsResourceHolder
the resource holder to process resourceHolder, Object the key that the ResourceHolder was bound for resourceKey)Overrides org. Release the given resource (after it has been unbound from the thread). |
| protected boolean | shouldReleaseBeforeCompletion()
Overrides org. Return whether this holder's resource should be released before
transaction completion ( |
| commitProcessed | back to summary |
|---|---|
| private boolean commitProcessed | |
| transacted | back to summary |
|---|---|
| private final boolean transacted | |
| JmsResourceSynchronization | back to summary |
|---|---|
| public JmsResourceSynchronization(JmsResourceHolder resourceHolder, Object resourceKey, boolean transacted) | |
| afterCompletion | back to summary |
|---|---|
| public void afterCompletion(int status) Overrides org. Overrides default org. Doc from org. Invoked after transaction commit/rollback. Can perform resource cleanup after transaction completion. Note The transaction will have been committed or rolled back already,
but the transactional resources might still be active and accessible. As a
consequence, any data access code triggered at this point will still "participate"
in the original transaction, allowing to perform some cleanup (with no commit
following anymore!), unless it explicitly declares that it needs to run in a
separate transaction. Hence: Use
| |
| processResourceAfterCommit | back to summary |
|---|---|
| protected void processResourceAfterCommit(JmsResourceHolder resourceHolder) Overrides org. Doc from org. After-commit callback for the given resource holder.
Only called when the resource hasn't been released yet
(
| |
| releaseResource | back to summary |
|---|---|
| protected void releaseResource(JmsResourceHolder resourceHolder, Object resourceKey) Overrides org. Doc from org. Release the given resource (after it has been unbound from the thread).
| |
| shouldReleaseBeforeCompletion | back to summary |
|---|---|
| protected boolean shouldReleaseBeforeCompletion() Overrides org. Doc from org. Return whether this holder's resource should be released before
transaction completion ( Note that resources will only be released when they are
unbound from the thread ( The default implementation returns
| |
doGetTransactionalSession method.
| Modifier and Type | Method and Description |
|---|---|
| public Connection | Returns: the new JMS ConnectionCreate a new JMS Connection for registration with a JmsResourceHolder. |
| public Session | Returns: the new JMS Sessionthe JMS Connection to create a Session for con)Create a new JMS Session for registration with a JmsResourceHolder. |
| public Connection | Returns: an appropriate Connection fetched from the holder, ornull if none foundthe JmsResourceHolder holder)Fetch an appropriate Connection from the given JmsResourceHolder. |
| public Session | Returns: an appropriate Session fetched from the holder, ornull if none foundthe JmsResourceHolder holder)Fetch an appropriate Session from the given JmsResourceHolder. |
| public boolean | Returns: whether to allow for synchronizing a local JMS transactionReturn 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. |
| createConnection | back to summary |
|---|---|
| public Connection createConnection() throws JMSException Create a new JMS Connection for registration with a JmsResourceHolder.
| |
| createSession | back to summary |
|---|---|
| public Session createSession(Connection con) throws JMSException Create a new JMS Session for registration with a JmsResourceHolder.
| |
| getConnection | back to summary |
|---|---|
| public Connection getConnection(JmsResourceHolder holder) Fetch an appropriate Connection from the given JmsResourceHolder.
| |
| getSession | back to summary |
|---|---|
| public Session getSession(JmsResourceHolder holder) Fetch an appropriate Session from the given JmsResourceHolder.
| |
| isSynchedLocalTransactionAllowed | back to summary |
|---|---|
| public boolean isSynchedLocalTransactionAllowed() Return 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.
| |