Example usage for javax.jms QueueSession createBrowser

List of usage examples for javax.jms QueueSession createBrowser

Introduction

In this page you can find the example usage for javax.jms QueueSession createBrowser.

Prototype


QueueBrowser createBrowser(Queue queue, String messageSelector) throws JMSException;

Source Link

Document

Creates a QueueBrowser object to peek at the messages on the specified queue using a message selector.

Usage

From source file:nl.nn.adapterframework.jms.JmsMessageBrowser.java

protected Message doBrowse(Map selectors) throws ListenerException {
    QueueSession session = null;
    Message msg = null;/*from   w w  w .  ja v  a 2 s.  co  m*/
    QueueBrowser queueBrowser = null;
    try {
        session = (QueueSession) createSession();
        queueBrowser = session.createBrowser((Queue) getDestination(), getCombinedSelector(selectors));
        Enumeration msgenum = queueBrowser.getEnumeration();
        if (msgenum.hasMoreElements()) {
            msg = (Message) msgenum.nextElement();
        }
        return msg;
    } catch (Exception e) {
        throw new ListenerException(e);
    } finally {
        try {
            if (queueBrowser != null) {
                queueBrowser.close();
            }
        } catch (JMSException e1) {
            throw new ListenerException("exception closing queueBrowser", e1);
        }
        closeSession(session);
    }
}