List of usage examples for javax.jms Session createBrowser
QueueBrowser createBrowser(Queue queue, String messageSelector) throws JMSException;
From source file:com.ccc.ccm.client.JMSTemplateAutowired.java
/** * Create a JMS MessageProducer for the given Session and Destination, * configuring it to disable message ids and/or timestamps (if necessary). * <p>Delegates to {@link #doCreateProducer} for creation of the raw * JMS MessageProducer, which needs to be specific to JMS 1.1 or 1.0.2. * @param session the JMS Session to create a QueueBrowser for * @param queue the JMS Queue to create a QueueBrowser for * @param messageSelector the message selector for this consumer (can be <code>null</code>) * @return the new JMS QueueBrowser//from www.jav a 2 s. co m * @throws JMSException if thrown by JMS API methods * @see #setMessageIdEnabled * @see #setMessageTimestampEnabled */ protected QueueBrowser createBrowser(Session session, Queue queue, String messageSelector) throws JMSException { return session.createBrowser(queue, messageSelector); }
From source file:tools.ConsumerTool.java
public void runQueueBrowser(Session session, Queue queue) throws JMSException, InterruptedException { QueueBrowser browser = null;/*from ww w .j a v a2 s . c o m*/ if (selector != null) { browser = session.createBrowser(queue, selector); } else { 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(); }