Example usage for javax.jms QueueBrowser QueueBrowser

List of usage examples for javax.jms QueueBrowser QueueBrowser

Introduction

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

Prototype

QueueBrowser

Source Link

Usage

From source file:hermes.ext.jbossmq.JBossMQAdmin.java

public QueueBrowser createDurableSubscriptionBrowser(final DestinationConfig dConfig) throws JMSException {
    try {//from w w  w  .  j  a  v  a 2  s . c o m
        final ObjectName objectName = new ObjectName(
                "jboss.mq.destination:name=" + getRealDestinationName(dConfig) + ",service=Topic");

        String[] params;
        String[] signature;

        if (dConfig.getSelector() == null) {
            params = new String[] { getHermes().getConnection().getClientID(), dConfig.getClientID() };
            signature = new String[] { String.class.getName(), String.class.getName() };
        } else {
            params = new String[] { getHermes().getConnection().getClientID(), dConfig.getClientID(),
                    dConfig.getSelector() };
            signature = new String[] { String.class.getName(), String.class.getName(), String.class.getName() };
        }

        final Collection messages = (Collection) getRMIAdapter().invoke(objectName, "listDurableMessages",
                params, signature);

        return new QueueBrowser() {

            public void close() throws JMSException {
                // TODO Auto-generated method stub               
            }

            public Enumeration getEnumeration() throws JMSException {
                return new IteratorEnumeration(messages.iterator());
            }

            public String getMessageSelector() throws JMSException {
                return dConfig.getSelector();
            }

            public Queue getQueue() throws JMSException {
                // TODO Auto-generated method stub
                return null;
            }
        };
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        throw new HermesException(e);
    }
}