Class ActiveMQRASession

  • All Implemented Interfaces:
    java.lang.AutoCloseable, java.lang.Runnable, javax.jms.QueueSession, javax.jms.Session, javax.jms.TopicSession, javax.jms.XAQueueSession, javax.jms.XASession, javax.jms.XATopicSession

    public class ActiveMQRASession
    extends java.lang.Object
    implements javax.jms.QueueSession, javax.jms.TopicSession, javax.jms.XAQueueSession, javax.jms.XATopicSession
    A joint interface for JMS sessions
    • Field Summary

      • Fields inherited from interface javax.jms.Session

        AUTO_ACKNOWLEDGE, CLIENT_ACKNOWLEDGE, DUPS_OK_ACKNOWLEDGE, SESSION_TRANSACTED
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void checkState()  
      void close()
      Closes the session.
      void commit()
      Commit
      javax.jms.QueueBrowser createBrowser​(javax.jms.Queue queue)
      Create a browser
      javax.jms.QueueBrowser createBrowser​(javax.jms.Queue queue, java.lang.String messageSelector)
      Create a browser
      javax.jms.BytesMessage createBytesMessage()
      Create a bytes message
      javax.jms.MessageConsumer createConsumer​(javax.jms.Destination destination)
      Create a message consumer
      javax.jms.MessageConsumer createConsumer​(javax.jms.Destination destination, java.lang.String messageSelector)
      Create a message consumer
      javax.jms.MessageConsumer createConsumer​(javax.jms.Destination destination, java.lang.String messageSelector, boolean noLocal)
      Create a message consumer
      javax.jms.MessageConsumer createDurableConsumer​(javax.jms.Topic topic, java.lang.String name)  
      javax.jms.MessageConsumer createDurableConsumer​(javax.jms.Topic topic, java.lang.String name, java.lang.String messageSelector, boolean noLocal)  
      javax.jms.TopicSubscriber createDurableSubscriber​(javax.jms.Topic topic, java.lang.String name)
      Create a durable topic subscriber
      javax.jms.TopicSubscriber createDurableSubscriber​(javax.jms.Topic topic, java.lang.String name, java.lang.String messageSelector, boolean noLocal)
      Create a topic subscriber
      javax.jms.MapMessage createMapMessage()
      Create a map message
      javax.jms.Message createMessage()
      Create a message
      javax.jms.ObjectMessage createObjectMessage()
      Create an object message
      javax.jms.ObjectMessage createObjectMessage​(java.io.Serializable object)
      Create an object message
      javax.jms.MessageProducer createProducer​(javax.jms.Destination destination)
      Create a message producer
      javax.jms.TopicPublisher createPublisher​(javax.jms.Topic topic)
      Create a topic publisher
      javax.jms.Queue createQueue​(java.lang.String queueName)
      Create a queue
      javax.jms.QueueReceiver createReceiver​(javax.jms.Queue queue)
      Create a queue receiver
      javax.jms.QueueReceiver createReceiver​(javax.jms.Queue queue, java.lang.String messageSelector)
      Create a queue receiver
      javax.jms.QueueSender createSender​(javax.jms.Queue queue)
      Create a queue sender
      javax.jms.MessageConsumer createSharedConsumer​(javax.jms.Topic topic, java.lang.String sharedSubscriptionName)  
      javax.jms.MessageConsumer createSharedConsumer​(javax.jms.Topic topic, java.lang.String sharedSubscriptionName, java.lang.String messageSelector)  
      javax.jms.MessageConsumer createSharedDurableConsumer​(javax.jms.Topic topic, java.lang.String name)  
      javax.jms.MessageConsumer createSharedDurableConsumer​(javax.jms.Topic topic, java.lang.String name, java.lang.String messageSelector)  
      javax.jms.StreamMessage createStreamMessage()
      Create a stream message
      javax.jms.TopicSubscriber createSubscriber​(javax.jms.Topic topic)
      Create a topic subscriber
      javax.jms.TopicSubscriber createSubscriber​(javax.jms.Topic topic, java.lang.String messageSelector, boolean noLocal)
      Create a topic subscriber
      javax.jms.TemporaryQueue createTemporaryQueue()
      Create a temporary queue
      javax.jms.TemporaryTopic createTemporaryTopic()
      Create a temporary topic
      javax.jms.TextMessage createTextMessage()
      Create a text message
      javax.jms.TextMessage createTextMessage​(java.lang.String string)
      Create a text message
      javax.jms.Topic createTopic​(java.lang.String topicName)
      Create a topic
      int getAcknowledgeMode()
      Get the acknowledge mode
      javax.resource.spi.ManagedConnection getManagedConnection()
      for tests only
      javax.jms.MessageListener getMessageListener()
      Get the message listener -- throws IllegalStateException
      java.lang.String getNodeId()
      Returns the ID of the Node that this session is associated with.
      javax.jms.QueueSession getQueueSession()
      Get the queue session
      javax.jms.Session getSession()
      Get the session
      javax.jms.TopicSession getTopicSession()
      Get the topic session
      boolean getTransacted()
      Get transacted
      javax.transaction.xa.XAResource getXAResource()
      Get the XA resource
      protected void lock()
      Lock
      void recover()
      Recover
      void rollback()
      Rollback
      void run()
      Always throws an Error.
      void setActiveMQSessionFactory​(ActiveMQRASessionFactory sf)
      Set the session factory
      void setMessageListener​(javax.jms.MessageListener listener)
      Set the message listener -- Throws IllegalStateException
      protected void unlock()
      Unlock
      void unsubscribe​(java.lang.String name)
      Unsubscribe
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • setActiveMQSessionFactory

        public void setActiveMQSessionFactory​(ActiveMQRASessionFactory sf)
        Set the session factory
        Parameters:
        sf - The session factory
      • lock

        protected void lock()
                     throws javax.jms.JMSException
        Lock
        Throws:
        javax.jms.JMSException - Thrown if an error occurs
        javax.jms.IllegalStateException - The session is closed
      • unlock

        protected void unlock()
        Unlock
      • createBytesMessage

        public javax.jms.BytesMessage createBytesMessage()
                                                  throws javax.jms.JMSException
        Create a bytes message
        Specified by:
        createBytesMessage in interface javax.jms.Session
        Returns:
        The message
        Throws:
        javax.jms.JMSException - Thrown if an error occurs
      • createMapMessage

        public javax.jms.MapMessage createMapMessage()
                                              throws javax.jms.JMSException
        Create a map message
        Specified by:
        createMapMessage in interface javax.jms.Session
        Returns:
        The message
        Throws:
        javax.jms.JMSException - Thrown if an error occurs
      • createMessage

        public javax.jms.Message createMessage()
                                        throws javax.jms.JMSException
        Create a message
        Specified by:
        createMessage in interface javax.jms.Session
        Returns:
        The message
        Throws:
        javax.jms.JMSException - Thrown if an error occurs
      • createObjectMessage

        public javax.jms.ObjectMessage createObjectMessage()
                                                    throws javax.jms.JMSException
        Create an object message
        Specified by:
        createObjectMessage in interface javax.jms.Session
        Returns:
        The message
        Throws:
        javax.jms.JMSException - Thrown if an error occurs
      • createObjectMessage

        public javax.jms.ObjectMessage createObjectMessage​(java.io.Serializable object)
                                                    throws javax.jms.JMSException
        Create an object message
        Specified by:
        createObjectMessage in interface javax.jms.Session
        Parameters:
        object - The object
        Returns:
        The message
        Throws:
        javax.jms.JMSException - Thrown if an error occurs
      • createStreamMessage

        public javax.jms.StreamMessage createStreamMessage()
                                                    throws javax.jms.JMSException
        Create a stream message
        Specified by:
        createStreamMessage in interface javax.jms.Session
        Returns:
        The message
        Throws:
        javax.jms.JMSException - Thrown if an error occurs
      • createTextMessage

        public javax.jms.TextMessage createTextMessage()
                                                throws javax.jms.JMSException
        Create a text message
        Specified by:
        createTextMessage in interface javax.jms.Session
        Returns:
        The message
        Throws:
        javax.jms.JMSException - Thrown if an error occurs
      • createTextMessage

        public javax.jms.TextMessage createTextMessage​(java.lang.String string)
                                                throws javax.jms.JMSException
        Create a text message
        Specified by:
        createTextMessage in interface javax.jms.Session
        Parameters:
        string - The text
        Returns:
        The message
        Throws:
        javax.jms.JMSException - Thrown if an error occurs
      • getTransacted

        public boolean getTransacted()
                              throws javax.jms.JMSException
        Get transacted
        Specified by:
        getTransacted in interface javax.jms.Session
        Specified by:
        getTransacted in interface javax.jms.XASession
        Returns:
        True if transacted; otherwise false
        Throws:
        javax.jms.JMSException - Thrown if an error occurs
      • getMessageListener

        public javax.jms.MessageListener getMessageListener()
                                                     throws javax.jms.JMSException
        Get the message listener -- throws IllegalStateException
        Specified by:
        getMessageListener in interface javax.jms.Session
        Returns:
        The message listener
        Throws:
        javax.jms.JMSException - Thrown if an error occurs
      • setMessageListener

        public void setMessageListener​(javax.jms.MessageListener listener)
                                throws javax.jms.JMSException
        Set the message listener -- Throws IllegalStateException
        Specified by:
        setMessageListener in interface javax.jms.Session
        Parameters:
        listener - The message listener
        Throws:
        javax.jms.JMSException - Thrown if an error occurs
      • run

        public void run()
        Always throws an Error.
        Specified by:
        run in interface java.lang.Runnable
        Specified by:
        run in interface javax.jms.Session
        Throws:
        java.lang.Error - Method not allowed.
      • close

        public void close()
                   throws javax.jms.JMSException
        Closes the session. Sends a ConnectionEvent.CONNECTION_CLOSED to the managed connection.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface javax.jms.Session
        Throws:
        javax.jms.JMSException - Failed to close session.
      • commit

        public void commit()
                    throws javax.jms.JMSException
        Commit
        Specified by:
        commit in interface javax.jms.Session
        Specified by:
        commit in interface javax.jms.XASession
        Throws:
        javax.jms.JMSException - Failed to close session.
      • rollback

        public void rollback()
                      throws javax.jms.JMSException
        Rollback
        Specified by:
        rollback in interface javax.jms.Session
        Specified by:
        rollback in interface javax.jms.XASession
        Throws:
        javax.jms.JMSException - Failed to close session.
      • recover

        public void recover()
                     throws javax.jms.JMSException
        Recover
        Specified by:
        recover in interface javax.jms.Session
        Throws:
        javax.jms.JMSException - Failed to close session.
      • createTopic

        public javax.jms.Topic createTopic​(java.lang.String topicName)
                                    throws javax.jms.JMSException
        Create a topic
        Specified by:
        createTopic in interface javax.jms.Session
        Specified by:
        createTopic in interface javax.jms.TopicSession
        Parameters:
        topicName - The topic name
        Returns:
        The topic
        Throws:
        javax.jms.JMSException - Thrown if an error occurs
      • createSubscriber

        public javax.jms.TopicSubscriber createSubscriber​(javax.jms.Topic topic)
                                                   throws javax.jms.JMSException
        Create a topic subscriber
        Specified by:
        createSubscriber in interface javax.jms.TopicSession
        Parameters:
        topic - The topic
        Returns:
        The subscriber
        Throws:
        javax.jms.JMSException - Thrown if an error occurs
      • createSubscriber

        public javax.jms.TopicSubscriber createSubscriber​(javax.jms.Topic topic,
                                                          java.lang.String messageSelector,
                                                          boolean noLocal)
                                                   throws javax.jms.JMSException
        Create a topic subscriber
        Specified by:
        createSubscriber in interface javax.jms.TopicSession
        Parameters:
        topic - The topic
        messageSelector - The message selector
        noLocal - If true inhibits the delivery of messages published by its own connection
        Returns:
        The subscriber
        Throws:
        javax.jms.JMSException - Thrown if an error occurs
      • createDurableSubscriber

        public javax.jms.TopicSubscriber createDurableSubscriber​(javax.jms.Topic topic,
                                                                 java.lang.String name)
                                                          throws javax.jms.JMSException
        Create a durable topic subscriber
        Specified by:
        createDurableSubscriber in interface javax.jms.Session
        Specified by:
        createDurableSubscriber in interface javax.jms.TopicSession
        Parameters:
        topic - The topic
        name - The name
        Returns:
        The subscriber
        Throws:
        javax.jms.JMSException - Thrown if an error occurs
      • createDurableSubscriber

        public javax.jms.TopicSubscriber createDurableSubscriber​(javax.jms.Topic topic,
                                                                 java.lang.String name,
                                                                 java.lang.String messageSelector,
                                                                 boolean noLocal)
                                                          throws javax.jms.JMSException
        Create a topic subscriber
        Specified by:
        createDurableSubscriber in interface javax.jms.Session
        Specified by:
        createDurableSubscriber in interface javax.jms.TopicSession
        Parameters:
        topic - The topic
        name - The name
        messageSelector - The message selector
        noLocal - If true inhibits the delivery of messages published by its own connection
        Returns:
        The subscriber
        Throws:
        javax.jms.JMSException - Thrown if an error occurs
      • createPublisher

        public javax.jms.TopicPublisher createPublisher​(javax.jms.Topic topic)
                                                 throws javax.jms.JMSException
        Create a topic publisher
        Specified by:
        createPublisher in interface javax.jms.TopicSession
        Parameters:
        topic - The topic
        Returns:
        The publisher
        Throws:
        javax.jms.JMSException - Thrown if an error occurs
      • createTemporaryTopic

        public javax.jms.TemporaryTopic createTemporaryTopic()
                                                      throws javax.jms.JMSException
        Create a temporary topic
        Specified by:
        createTemporaryTopic in interface javax.jms.Session
        Specified by:
        createTemporaryTopic in interface javax.jms.TopicSession
        Returns:
        The temporary topic
        Throws:
        javax.jms.JMSException - Thrown if an error occurs
      • unsubscribe

        public void unsubscribe​(java.lang.String name)
                         throws javax.jms.JMSException
        Unsubscribe
        Specified by:
        unsubscribe in interface javax.jms.Session
        Specified by:
        unsubscribe in interface javax.jms.TopicSession
        Parameters:
        name - The name
        Throws:
        javax.jms.JMSException - Thrown if an error occurs
      • createBrowser

        public javax.jms.QueueBrowser createBrowser​(javax.jms.Queue queue)
                                             throws javax.jms.JMSException
        Create a browser
        Specified by:
        createBrowser in interface javax.jms.QueueSession
        Specified by:
        createBrowser in interface javax.jms.Session
        Parameters:
        queue - The queue
        Returns:
        The browser
        Throws:
        javax.jms.JMSException - Thrown if an error occurs
      • createBrowser

        public javax.jms.QueueBrowser createBrowser​(javax.jms.Queue queue,
                                                    java.lang.String messageSelector)
                                             throws javax.jms.JMSException
        Create a browser
        Specified by:
        createBrowser in interface javax.jms.QueueSession
        Specified by:
        createBrowser in interface javax.jms.Session
        Parameters:
        queue - The queue
        messageSelector - The message selector
        Returns:
        The browser
        Throws:
        javax.jms.JMSException - Thrown if an error occurs
      • createQueue

        public javax.jms.Queue createQueue​(java.lang.String queueName)
                                    throws javax.jms.JMSException
        Create a queue
        Specified by:
        createQueue in interface javax.jms.QueueSession
        Specified by:
        createQueue in interface javax.jms.Session
        Parameters:
        queueName - The queue name
        Returns:
        The queue
        Throws:
        javax.jms.JMSException - Thrown if an error occurs
      • createReceiver

        public javax.jms.QueueReceiver createReceiver​(javax.jms.Queue queue)
                                               throws javax.jms.JMSException
        Create a queue receiver
        Specified by:
        createReceiver in interface javax.jms.QueueSession
        Parameters:
        queue - The queue
        Returns:
        The queue receiver
        Throws:
        javax.jms.JMSException - Thrown if an error occurs
      • createReceiver

        public javax.jms.QueueReceiver createReceiver​(javax.jms.Queue queue,
                                                      java.lang.String messageSelector)
                                               throws javax.jms.JMSException
        Create a queue receiver
        Specified by:
        createReceiver in interface javax.jms.QueueSession
        Parameters:
        queue - The queue
        messageSelector -
        Returns:
        The queue receiver
        Throws:
        javax.jms.JMSException - Thrown if an error occurs
      • createSender

        public javax.jms.QueueSender createSender​(javax.jms.Queue queue)
                                           throws javax.jms.JMSException
        Create a queue sender
        Specified by:
        createSender in interface javax.jms.QueueSession
        Parameters:
        queue - The queue
        Returns:
        The queue sender
        Throws:
        javax.jms.JMSException - Thrown if an error occurs
      • createTemporaryQueue

        public javax.jms.TemporaryQueue createTemporaryQueue()
                                                      throws javax.jms.JMSException
        Create a temporary queue
        Specified by:
        createTemporaryQueue in interface javax.jms.QueueSession
        Specified by:
        createTemporaryQueue in interface javax.jms.Session
        Returns:
        The temporary queue
        Throws:
        javax.jms.JMSException - Thrown if an error occurs
      • createConsumer

        public javax.jms.MessageConsumer createConsumer​(javax.jms.Destination destination)
                                                 throws javax.jms.JMSException
        Create a message consumer
        Specified by:
        createConsumer in interface javax.jms.Session
        Parameters:
        destination - The destination
        Returns:
        The message consumer
        Throws:
        javax.jms.JMSException - Thrown if an error occurs
      • createConsumer

        public javax.jms.MessageConsumer createConsumer​(javax.jms.Destination destination,
                                                        java.lang.String messageSelector)
                                                 throws javax.jms.JMSException
        Create a message consumer
        Specified by:
        createConsumer in interface javax.jms.Session
        Parameters:
        destination - The destination
        messageSelector - The message selector
        Returns:
        The message consumer
        Throws:
        javax.jms.JMSException - Thrown if an error occurs
      • createConsumer

        public javax.jms.MessageConsumer createConsumer​(javax.jms.Destination destination,
                                                        java.lang.String messageSelector,
                                                        boolean noLocal)
                                                 throws javax.jms.JMSException
        Create a message consumer
        Specified by:
        createConsumer in interface javax.jms.Session
        Parameters:
        destination - The destination
        messageSelector - The message selector
        noLocal - If true inhibits the delivery of messages published by its own connection
        Returns:
        The message consumer
        Throws:
        javax.jms.JMSException - Thrown if an error occurs
      • createProducer

        public javax.jms.MessageProducer createProducer​(javax.jms.Destination destination)
                                                 throws javax.jms.JMSException
        Create a message producer
        Specified by:
        createProducer in interface javax.jms.Session
        Parameters:
        destination - The destination
        Returns:
        The message producer
        Throws:
        javax.jms.JMSException - Thrown if an error occurs
      • getAcknowledgeMode

        public int getAcknowledgeMode()
                               throws javax.jms.JMSException
        Get the acknowledge mode
        Specified by:
        getAcknowledgeMode in interface javax.jms.Session
        Returns:
        The mode
        Throws:
        javax.jms.JMSException - Thrown if an error occurs
      • getXAResource

        public javax.transaction.xa.XAResource getXAResource()
        Get the XA resource
        Specified by:
        getXAResource in interface javax.jms.XASession
      • getNodeId

        public java.lang.String getNodeId()
                                   throws javax.jms.JMSException
        Returns the ID of the Node that this session is associated with.
        Returns:
        Node ID
        Throws:
        javax.jms.JMSException
      • getSession

        public javax.jms.Session getSession()
                                     throws javax.jms.JMSException
        Get the session
        Specified by:
        getSession in interface javax.jms.XASession
        Returns:
        The session
        Throws:
        javax.jms.JMSException - Thrown if an error occurs
      • getQueueSession

        public javax.jms.QueueSession getQueueSession()
                                               throws javax.jms.JMSException
        Get the queue session
        Specified by:
        getQueueSession in interface javax.jms.XAQueueSession
        Returns:
        The queue session
        Throws:
        javax.jms.JMSException - Thrown if an error occurs
      • getTopicSession

        public javax.jms.TopicSession getTopicSession()
                                               throws javax.jms.JMSException
        Get the topic session
        Specified by:
        getTopicSession in interface javax.jms.XATopicSession
        Returns:
        The topic session
        Throws:
        javax.jms.JMSException - Thrown if an error occurs
      • createSharedConsumer

        public javax.jms.MessageConsumer createSharedConsumer​(javax.jms.Topic topic,
                                                              java.lang.String sharedSubscriptionName)
                                                       throws javax.jms.JMSException
        Specified by:
        createSharedConsumer in interface javax.jms.Session
        Throws:
        javax.jms.JMSException
      • createSharedConsumer

        public javax.jms.MessageConsumer createSharedConsumer​(javax.jms.Topic topic,
                                                              java.lang.String sharedSubscriptionName,
                                                              java.lang.String messageSelector)
                                                       throws javax.jms.JMSException
        Specified by:
        createSharedConsumer in interface javax.jms.Session
        Throws:
        javax.jms.JMSException
      • createDurableConsumer

        public javax.jms.MessageConsumer createDurableConsumer​(javax.jms.Topic topic,
                                                               java.lang.String name)
                                                        throws javax.jms.JMSException
        Specified by:
        createDurableConsumer in interface javax.jms.Session
        Throws:
        javax.jms.JMSException
      • createDurableConsumer

        public javax.jms.MessageConsumer createDurableConsumer​(javax.jms.Topic topic,
                                                               java.lang.String name,
                                                               java.lang.String messageSelector,
                                                               boolean noLocal)
                                                        throws javax.jms.JMSException
        Specified by:
        createDurableConsumer in interface javax.jms.Session
        Throws:
        javax.jms.JMSException
      • createSharedDurableConsumer

        public javax.jms.MessageConsumer createSharedDurableConsumer​(javax.jms.Topic topic,
                                                                     java.lang.String name)
                                                              throws javax.jms.JMSException
        Specified by:
        createSharedDurableConsumer in interface javax.jms.Session
        Throws:
        javax.jms.JMSException
      • createSharedDurableConsumer

        public javax.jms.MessageConsumer createSharedDurableConsumer​(javax.jms.Topic topic,
                                                                     java.lang.String name,
                                                                     java.lang.String messageSelector)
                                                              throws javax.jms.JMSException
        Specified by:
        createSharedDurableConsumer in interface javax.jms.Session
        Throws:
        javax.jms.JMSException
      • getManagedConnection

        public javax.resource.spi.ManagedConnection getManagedConnection()
        for tests only
      • checkState

        public void checkState()
                        throws javax.jms.JMSException
        Throws:
        javax.jms.JMSException