Class ActiveMQConnection

  • All Implemented Interfaces:
    java.lang.AutoCloseable, javax.jms.Connection, javax.jms.QueueConnection, javax.jms.TopicConnection, ActiveMQConnectionForContext
    Direct Known Subclasses:
    ActiveMQXAConnection

    public class ActiveMQConnection
    extends ActiveMQConnectionForContextImpl
    implements javax.jms.TopicConnection, javax.jms.QueueConnection
    ActiveMQ Artemis implementation of a JMS Connection.

    The flat implementation of TopicConnection and QueueConnection is per design, following the common usage of these as one flat API in JMS 1.1.

    • Field Detail

      • TYPE_GENERIC_CONNECTION

        public static final int TYPE_GENERIC_CONNECTION
        See Also:
        Constant Field Values
      • EXCEPTION_FAILOVER

        public static final java.lang.String EXCEPTION_FAILOVER
        See Also:
        Constant Field Values
      • EXCEPTION_DISCONNECT

        public static final java.lang.String EXCEPTION_DISCONNECT
        See Also:
        Constant Field Values
      • CONNECTION_ID_PROPERTY_NAME

        public static final org.apache.activemq.artemis.api.core.SimpleString CONNECTION_ID_PROPERTY_NAME
    • Constructor Detail

      • ActiveMQConnection

        public ActiveMQConnection​(ConnectionFactoryOptions options,
                                  java.lang.String username,
                                  java.lang.String password,
                                  int connectionType,
                                  java.lang.String clientID,
                                  int dupsOKBatchSize,
                                  int transactionBatchSize,
                                  boolean cacheDestinations,
                                  boolean enable1xPrefixes,
                                  ClientSessionFactory sessionFactory)
    • Method Detail

      • createNonXASession

        public javax.jms.Session createNonXASession​(boolean transacted,
                                                    int acknowledgeMode)
                                             throws javax.jms.JMSException
        This internal method serves basically the Resource Adapter. The resource adapter plays with an XASession and a non XASession. When there is no enlisted transaction, the EE specification mandates that the commit should be done as if it was a nonXA Session (i.e. SessionTransacted). For that reason we have this method to force that nonXASession, since the JMS Javadoc mandates createSession to return a XASession.
        Throws:
        javax.jms.JMSException
      • createNonXATopicSession

        public javax.jms.Session createNonXATopicSession​(boolean transacted,
                                                         int acknowledgeMode)
                                                  throws javax.jms.JMSException
        This internal method serves basically the Resource Adapter. The resource adapter plays with an XASession and a non XASession. When there is no enlisted transaction, the EE specification mandates that the commit should be done as if it was a nonXA Session (i.e. SessionTransacted). For that reason we have this method to force that nonXASession, since the JMS Javadoc mandates createSession to return a XASession.
        Throws:
        javax.jms.JMSException
      • createNonXAQueueSession

        public javax.jms.Session createNonXAQueueSession​(boolean transacted,
                                                         int acknowledgeMode)
                                                  throws javax.jms.JMSException
        This internal method serves basically the Resource Adapter. The resource adapter plays with an XASession and a non XASession. When there is no enlisted transaction, the EE specification mandates that the commit should be done as if it was a nonXA Session (i.e. SessionTransacted). For that reason we have this method to force that nonXASession, since the JMS Javadoc mandates createSession to return a XASession.
        Throws:
        javax.jms.JMSException
      • createSession

        public javax.jms.Session createSession​(boolean transacted,
                                               int acknowledgeMode)
                                        throws javax.jms.JMSException
        Specified by:
        createSession in interface javax.jms.Connection
        Throws:
        javax.jms.JMSException
      • getClientID

        public java.lang.String getClientID()
                                     throws javax.jms.JMSException
        Specified by:
        getClientID in interface javax.jms.Connection
        Throws:
        javax.jms.JMSException
      • setClientID

        public void setClientID​(java.lang.String clientID)
                         throws javax.jms.JMSException
        Specified by:
        setClientID in interface javax.jms.Connection
        Throws:
        javax.jms.JMSException
      • getMetaData

        public javax.jms.ConnectionMetaData getMetaData()
                                                 throws javax.jms.JMSException
        Specified by:
        getMetaData in interface javax.jms.Connection
        Throws:
        javax.jms.JMSException
      • getExceptionListener

        public javax.jms.ExceptionListener getExceptionListener()
                                                         throws javax.jms.JMSException
        Specified by:
        getExceptionListener in interface javax.jms.Connection
        Throws:
        javax.jms.JMSException
      • setExceptionListener

        public void setExceptionListener​(javax.jms.ExceptionListener listener)
                                  throws javax.jms.JMSException
        Specified by:
        setExceptionListener in interface javax.jms.Connection
        Throws:
        javax.jms.JMSException
      • start

        public void start()
                   throws javax.jms.JMSException
        Specified by:
        start in interface javax.jms.Connection
        Throws:
        javax.jms.JMSException
      • signalStopToAllSessions

        public void signalStopToAllSessions()
      • stop

        public void stop()
                  throws javax.jms.JMSException
        Specified by:
        stop in interface javax.jms.Connection
        Throws:
        javax.jms.JMSException
      • close

        public final void close()
                         throws javax.jms.JMSException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface javax.jms.Connection
        Throws:
        javax.jms.JMSException
      • createConnectionConsumer

        public javax.jms.ConnectionConsumer createConnectionConsumer​(javax.jms.Destination destination,
                                                                     java.lang.String messageSelector,
                                                                     javax.jms.ServerSessionPool sessionPool,
                                                                     int maxMessages)
                                                              throws javax.jms.JMSException
        Specified by:
        createConnectionConsumer in interface javax.jms.Connection
        Throws:
        javax.jms.JMSException
      • createDurableConnectionConsumer

        public javax.jms.ConnectionConsumer createDurableConnectionConsumer​(javax.jms.Topic topic,
                                                                            java.lang.String subscriptionName,
                                                                            java.lang.String messageSelector,
                                                                            javax.jms.ServerSessionPool sessionPool,
                                                                            int maxMessages)
                                                                     throws javax.jms.JMSException
        Specified by:
        createDurableConnectionConsumer in interface javax.jms.Connection
        Specified by:
        createDurableConnectionConsumer in interface javax.jms.TopicConnection
        Throws:
        javax.jms.JMSException
      • createSession

        public javax.jms.Session createSession​(int sessionMode)
                                        throws javax.jms.JMSException
        Specified by:
        createSession in interface javax.jms.Connection
        Throws:
        javax.jms.JMSException
      • createSession

        public javax.jms.Session createSession()
                                        throws javax.jms.JMSException
        Specified by:
        createSession in interface javax.jms.Connection
        Throws:
        javax.jms.JMSException
      • createQueueSession

        public javax.jms.QueueSession createQueueSession​(boolean transacted,
                                                         int acknowledgeMode)
                                                  throws javax.jms.JMSException
        Specified by:
        createQueueSession in interface javax.jms.QueueConnection
        Throws:
        javax.jms.JMSException
      • checkAck

        public static int checkAck​(boolean transacted,
                                   int acknowledgeMode)
        I'm keeping this as static as the same check will be done within RA. This is to conform with TCK Tests where we must return ackMode exactly as they want if transacted=false
      • createConnectionConsumer

        public javax.jms.ConnectionConsumer createConnectionConsumer​(javax.jms.Queue queue,
                                                                     java.lang.String messageSelector,
                                                                     javax.jms.ServerSessionPool sessionPool,
                                                                     int maxMessages)
                                                              throws javax.jms.JMSException
        Specified by:
        createConnectionConsumer in interface javax.jms.QueueConnection
        Throws:
        javax.jms.JMSException
      • createTopicSession

        public javax.jms.TopicSession createTopicSession​(boolean transacted,
                                                         int acknowledgeMode)
                                                  throws javax.jms.JMSException
        Specified by:
        createTopicSession in interface javax.jms.TopicConnection
        Throws:
        javax.jms.JMSException
      • createConnectionConsumer

        public javax.jms.ConnectionConsumer createConnectionConsumer​(javax.jms.Topic topic,
                                                                     java.lang.String messageSelector,
                                                                     javax.jms.ServerSessionPool sessionPool,
                                                                     int maxMessages)
                                                              throws javax.jms.JMSException
        Specified by:
        createConnectionConsumer in interface javax.jms.TopicConnection
        Throws:
        javax.jms.JMSException
      • createSharedConnectionConsumer

        public javax.jms.ConnectionConsumer createSharedConnectionConsumer​(javax.jms.Topic topic,
                                                                           java.lang.String subscriptionName,
                                                                           java.lang.String messageSelector,
                                                                           javax.jms.ServerSessionPool sessionPool,
                                                                           int maxMessages)
                                                                    throws javax.jms.JMSException
        Specified by:
        createSharedConnectionConsumer in interface javax.jms.Connection
        Throws:
        javax.jms.JMSException
      • createSharedDurableConnectionConsumer

        public javax.jms.ConnectionConsumer createSharedDurableConnectionConsumer​(javax.jms.Topic topic,
                                                                                  java.lang.String subscriptionName,
                                                                                  java.lang.String messageSelector,
                                                                                  javax.jms.ServerSessionPool sessionPool,
                                                                                  int maxMessages)
                                                                           throws javax.jms.JMSException
        Specified by:
        createSharedDurableConnectionConsumer in interface javax.jms.Connection
        Throws:
        javax.jms.JMSException
      • setFailoverListener

        public void setFailoverListener​(FailoverEventListener listener)
                                 throws javax.jms.JMSException
        Sets a FailureListener for the session which is notified if a failure occurs on the session.
        Parameters:
        listener - the listener to add
        Throws:
        javax.jms.JMSException
      • getFailoverListener

        public FailoverEventListener getFailoverListener()
                                                  throws javax.jms.JMSException
        Returns:
        FailoverEventListener the current failover event listener for this connection
        Throws:
        javax.jms.JMSException
      • addTemporaryQueue

        public void addTemporaryQueue​(org.apache.activemq.artemis.api.core.SimpleString queueAddress)
      • removeTemporaryQueue

        public void removeTemporaryQueue​(org.apache.activemq.artemis.api.core.SimpleString queueAddress)
      • containsTemporaryQueue

        public boolean containsTemporaryQueue​(org.apache.activemq.artemis.api.core.SimpleString queueAddress)
      • hasNoLocal

        public boolean hasNoLocal()
      • setHasNoLocal

        public void setHasNoLocal()
      • getUID

        public org.apache.activemq.artemis.api.core.SimpleString getUID()
      • isXA

        protected boolean isXA()
      • createSessionInternal

        protected final ActiveMQSession createSessionInternal​(boolean isXA,
                                                              boolean transacted,
                                                              int acknowledgeMode,
                                                              int type)
                                                       throws javax.jms.JMSException
        Throws:
        javax.jms.JMSException
      • createAMQSession

        protected ActiveMQSession createAMQSession​(boolean isXA,
                                                   boolean transacted,
                                                   int acknowledgeMode,
                                                   ClientSession session,
                                                   int type)
        Parameters:
        transacted -
        acknowledgeMode -
        session -
        type -
        Returns:
      • checkClosed

        protected final void checkClosed()
                                  throws javax.jms.JMSException
        Throws:
        javax.jms.JMSException
      • authorize

        public void authorize()
                       throws javax.jms.JMSException
        Throws:
        javax.jms.JMSException
      • authorize

        public void authorize​(boolean validateClientId)
                       throws javax.jms.JMSException
        Throws:
        javax.jms.JMSException
      • isStarted

        public boolean isStarted()
      • getDeserializationBlackList

        public java.lang.String getDeserializationBlackList()
      • getDeserializationWhiteList

        public java.lang.String getDeserializationWhiteList()