Class QueueBrowser

  • All Implemented Interfaces:
    jakarta.jms.QueueBrowser, AutoCloseable

    public class QueueBrowser
    extends Object
    implements jakarta.jms.QueueBrowser
    Implements the jakarta.jms.QueueBrowser interface.

    A client uses a QueueBrowser object to look at messages on a queue without removing them.

    The getEnumeration method returns a java.util.Enumeration that is used to scan the queue's messages. It may be an enumeration of the entire content of a queue, or it may contain only the messages matching a message selector.

    A QueueBrowser can be created from either a Session or a QueueSession.

    • Field Detail

      • logger

        private static Logger logger
      • DEBUG

        private static final boolean DEBUG
      • sess

        private Session sess
        The session the browser belongs to.
      • queue

        private Queue queue
        The queue the browser browses.
      • selector

        private String selector
        The selector for filtering messages.
      • closed

        private boolean closed
        true if the browser is closed.
    • Constructor Detail

      • QueueBrowser

        QueueBrowser​(Session sess,
                     Queue queue,
                     String selector)
              throws jakarta.jms.JMSException
        Constructs a browser.
        Parameters:
        sess - The session the browser belongs to.
        queue - The queue the browser browses.
        selector - The selector for filtering messages.
        Throws:
        jakarta.jms.InvalidDestinationException - if an invalid destination is specified.
        jakarta.jms.InvalidSelectorException - If the selector syntax is invalid.
        jakarta.jms.IllegalStateException - If the connection is broken.
        jakarta.jms.JMSException - If the creation fails for any other reason.
    • Method Detail

      • toString

        public String toString()
        Returns a string view of this browser.
        Overrides:
        toString in class Object
      • getQueue

        public jakarta.jms.Queue getQueue()
                                   throws jakarta.jms.JMSException
        API method.
        Specified by:
        getQueue in interface jakarta.jms.QueueBrowser
        Throws:
        jakarta.jms.IllegalStateException - If the browser is closed.
        jakarta.jms.JMSException
      • getMessageSelector

        public String getMessageSelector()
                                  throws jakarta.jms.JMSException
        API method. Gets this queue browser's message selector expression.
        Specified by:
        getMessageSelector in interface jakarta.jms.QueueBrowser
        Returns:
        this queue browser's message selector, or null if no message selector exists for the message consumer.
        Throws:
        jakarta.jms.IllegalStateException - If the browser is closed.
        jakarta.jms.JMSException
      • getEnumeration

        public Enumeration getEnumeration()
                                   throws jakarta.jms.JMSException
        API method. Gets an enumeration for browsing the current queue messages in the order they would be received.
        Specified by:
        getEnumeration in interface jakarta.jms.QueueBrowser
        Returns:
        an enumeration for browsing the messages.
        Throws:
        jakarta.jms.IllegalStateException - If the browser is closed, or if the connection is broken.
        jakarta.jms.JMSSecurityException - If the client is not a READER on the queue.
        jakarta.jms.JMSException - If the request fails for any other reason.
      • close

        public void close()
                   throws jakarta.jms.JMSException
        API method. Closes the QueueBrowser.

        In order to free significant resources allocated on behalf of a QueueBrowser, clients should close them when they are not needed.

        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in interface jakarta.jms.QueueBrowser
        Throws:
        jakarta.jms.JMSException - Actually never thrown.