类 ConnectionFactoryUtils

    • 方法详细资料

      • getTargetSession

        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.
        参数:
        session - the Session proxy to unwrap
        返回:
        the innermost target Session, or the passed-in one if no proxy
        另请参阅:
        SessionProxy.getTargetSession()
      • isSessionTransactional

        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.
        参数:
        session - the JMS Session to check
        cf - the JMS ConnectionFactory that the Session originated from
        返回:
        whether the Session is transactional
      • 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.
        参数:
        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.
        返回:
        the transactional Session, or null if none found
        抛出:
        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.

        参数:
        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.
        返回:
        the transactional Session, or null if none found
        抛出:
        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.

        参数:
        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.
        返回:
        the transactional Session, or null if none found
        抛出:
        JMSException - in case of JMS failure
      • doGetTransactionalSession

        public static Session doGetTransactionalSession​(ConnectionFactory connectionFactory,
                                                        ConnectionFactoryUtils.ResourceFactory resourceFactory,
                                                        boolean startConnection)
                                                 throws JMSException
        Obtain a JMS Session that is synchronized with the current transaction, if any.
        参数:
        connectionFactory - the JMS ConnectionFactory to bind for (used as TransactionSynchronizationManager key)
        resourceFactory - the ResourceFactory to use for extracting or creating JMS resources
        startConnection - 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 false.
        返回:
        the transactional Session, or null if none found
        抛出:
        JMSException - in case of JMS failure