Class JmsMessageConsumer

    • Field Detail

      • acknowledgementMode

        protected final int acknowledgementMode
      • messageListener

        protected volatile javax.jms.MessageListener messageListener
      • lock

        protected final Lock lock
      • deliveryTask

        protected final org.apache.qpid.jms.JmsMessageConsumer.MessageDeliverTask deliveryTask
      • address

        protected final String address
    • Constructor Detail

      • JmsMessageConsumer

        protected JmsMessageConsumer​(JmsConsumerId consumerId,
                                     JmsSession session,
                                     JmsDestination destination,
                                     String selector,
                                     boolean noLocal)
                              throws javax.jms.JMSException
        Throws:
        javax.jms.JMSException
    • Method Detail

      • init

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

        public void close()
                   throws javax.jms.JMSException
        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in interface javax.jms.MessageConsumer
        Throws:
        javax.jms.JMSException
      • doClose

        protected void doClose()
                        throws javax.jms.JMSException
        Called to initiate shutdown of Producer resources and request that the remote peer remove the registered producer.
        Throws:
        javax.jms.JMSException - if an error occurs during the consumer close operation.
      • shutdown

        protected void shutdown()
                         throws javax.jms.JMSException
        Called to release all producer resources without requiring a destroy request to be sent to the remote peer. This is most commonly needed when the parent Session is closing.
        Throws:
        javax.jms.JMSException - if an error occurs during shutdown.
      • shutdown

        protected void shutdown​(Throwable cause)
                         throws javax.jms.JMSException
        Throws:
        javax.jms.JMSException
      • receive

        public javax.jms.Message receive()
                                  throws javax.jms.JMSException
        Specified by:
        receive in interface javax.jms.MessageConsumer
        Throws:
        javax.jms.JMSException
      • receive

        public javax.jms.Message receive​(long timeout)
                                  throws javax.jms.JMSException
        Specified by:
        receive in interface javax.jms.MessageConsumer
        Throws:
        javax.jms.JMSException
      • receiveNoWait

        public javax.jms.Message receiveNoWait()
                                        throws javax.jms.JMSException
        Specified by:
        receiveNoWait in interface javax.jms.MessageConsumer
        Throws:
        javax.jms.JMSException
      • receiveBody

        public <T> T receiveBody​(Class<T> desired,
                                 long timeout)
                          throws javax.jms.JMSException
        Reads the next available message for this consumer and returns the body of that message if the type requested matches that of the message. The amount of time this method blocks is based on the timeout value. timeout < 0 then it blocks until a message is received. timeout = 0 then it returns the body immediately or null if none available. timeout > 0 then it blocks up to timeout amount of time.
        Parameters:
        desired - The type to assign the body of the message to for return.
        timeout - The time to wait for an incoming message before this method returns null.
        Returns:
        the assigned body of the next available message or null if the consumer is closed or the specified timeout elapses.
        Throws:
        javax.jms.MessageFormatException - if the message body cannot be assigned to the requested type.
        javax.jms.JMSException - if an error occurs while receiving the next message.
      • checkClosed

        protected void checkClosed()
                            throws javax.jms.IllegalStateException
        Throws:
        javax.jms.IllegalStateException
      • onInboundMessage

        public void onInboundMessage​(JmsInboundMessageDispatch envelope)
        Called from the session when a new Message has been dispatched to this Consumer from the connection.
        Specified by:
        onInboundMessage in interface JmsMessageDispatcher
        Parameters:
        envelope - the newly arrived message.
      • start

        public void start()
      • stop

        public void stop()
      • getConsumerId

        public JmsConsumerId getConsumerId()
        Returns:
        the id
      • getDestination

        public JmsDestination getDestination()
        Returns:
        the Destination
      • getMessageListener

        public javax.jms.MessageListener getMessageListener()
                                                     throws javax.jms.JMSException
        Specified by:
        getMessageListener in interface javax.jms.MessageConsumer
        Throws:
        javax.jms.JMSException
      • setMessageListener

        public void setMessageListener​(javax.jms.MessageListener listener)
                                throws javax.jms.JMSException
        Specified by:
        setMessageListener in interface javax.jms.MessageConsumer
        Throws:
        javax.jms.JMSException
      • getMessageSelector

        public String getMessageSelector()
                                  throws javax.jms.JMSException
        Specified by:
        getMessageSelector in interface javax.jms.MessageConsumer
        Throws:
        javax.jms.JMSException
      • getPrefetchSize

        public int getPrefetchSize()
        Gets the configured prefetch size for this consumer.
        Returns:
        the prefetch size configuration for this consumer.
      • checkMessageListener

        protected void checkMessageListener()
                                     throws javax.jms.JMSException
        Throws:
        javax.jms.JMSException
      • getMessageQueueSize

        protected int getMessageQueueSize()
      • isNoLocal

        protected boolean isNoLocal()
      • isDurableSubscription

        public boolean isDurableSubscription()
      • isSharedSubscription

        public boolean isSharedSubscription()
      • isBrowser

        public boolean isBrowser()
      • isPullConsumer

        public boolean isPullConsumer()
      • onConnectionInterrupted

        protected void onConnectionInterrupted()
      • onConnectionRestored

        protected void onConnectionRestored()
      • performPullIfRequired

        protected boolean performPullIfRequired​(long timeout,
                                                boolean treatAsPullConsumer)
                                         throws javax.jms.JMSException
        Triggers a pull request from the connected Provider with the given timeout value if the consumer is a pull consumer or requested to be treated as one, and the local queue is still running, and is currently empty.

        The timeout value can be one of:
        < 0 to indicate that the request should never time out.
        = 0 to indicate that the request should expire immediately if no message.
        > 0 to indicate that the request should expire after the given time in milliseconds.

        Parameters:
        timeout - The amount of time the pull request should remain valid.
        treatAsPullConsumer - Treat the consumer as if it were a pull consumer, even if it isn't.
        Returns:
        true if a pull was performed, false if it was not.
        Throws:
        javax.jms.JMSException