Class ActiveMQRASession

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

    public class ActiveMQRASession
    extends Object
    implements javax.jms.QueueSession, javax.jms.TopicSession, javax.jms.XAQueueSession, javax.jms.XATopicSession
    A joint interface for JMS sessions
    • 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​(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​(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 Runnable
        Specified by:
        run in interface javax.jms.Session
        Throws:
        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 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​(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,
                                                          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,
                                                                 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,
                                                                 String name,
                                                                 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​(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,
                                                    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​(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,
                                                      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,
                                                        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,
                                                        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 XAResource getXAResource()
        Get the XA resource
        Specified by:
        getXAResource in interface javax.jms.XASession
      • getNodeId

        public 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,
                                                              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,
                                                              String sharedSubscriptionName,
                                                              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,
                                                               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,
                                                               String name,
                                                               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,
                                                                     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,
                                                                     String name,
                                                                     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