List of usage examples for javax.jms QueueBrowser close
void close() throws JMSException;
From source file:tools.ConsumerTool.java
public void runQueueBrowser(Session session, Queue queue) throws JMSException, InterruptedException { QueueBrowser browser = null; if (selector != null) { browser = session.createBrowser(queue, selector); } else {/*from www .j a v a2s . c o m*/ browser = session.createBrowser(queue); } Enumeration messages = browser.getEnumeration(); int perConsumerReceivedMessages = 0; while (perConsumerReceivedMessages < numMessages) { if (messages != null) { while (messages.hasMoreElements()) { Message message = (Message) messages.nextElement(); if (message != null) { perConsumerReceivedMessages++; handleMessage(session, message, perConsumerReceivedMessages); } } } Thread.sleep(receiveTimeoutMS); messages = browser.getEnumeration(); } browser.close(); }