javax.jms.QueueBrowser Java Examples
The following examples show how to use
javax.jms.QueueBrowser.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JmsTemplate.java From spring-analysis-note with MIT License | 6 votes |
@Override @Nullable public <T> T browseSelected(final String queueName, @Nullable final String messageSelector, final BrowserCallback<T> action) throws JmsException { Assert.notNull(action, "Callback object must not be null"); return execute(session -> { Queue queue = (Queue) getDestinationResolver().resolveDestinationName(session, queueName, false); QueueBrowser browser = createBrowser(session, queue, messageSelector); try { return action.doInJms(session, browser); } finally { JmsUtils.closeQueueBrowser(browser); } }, true); }
Example #2
Source File: QueueCheck.java From activemq-artemis with Apache License 2.0 | 6 votes |
private void checkQueueBrowse(final CheckContext context) throws Exception { try (Connection connection = context.getFactory().createConnection(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); QueueBrowser queueBrowser = session.createBrowser(session.createQueue(getName()))) { connection.start(); Enumeration<Message> queueBrowserEnum = queueBrowser.getEnumeration(); if (browse == -1) { queueBrowserEnum.hasMoreElements(); } else { int count = 0; while (count < browse) { if (!queueBrowserEnum.hasMoreElements() || queueBrowserEnum.nextElement() == null) { throw new CheckException("Insufficient messages to browse: " + count); } count++; } } } }
Example #3
Source File: AbstractPersistentStatTestSupport.java From activemq-artemis with Apache License 2.0 | 6 votes |
protected void browseTestQueueMessages(String queueName) throws Exception { // Start the connection Connection connection = cf.createConnection(); connection.setClientID("clientId2" + queueName); connection.start(); Session session = connection.createSession(false, QueueSession.AUTO_ACKNOWLEDGE); Queue queue = session.createQueue(queueName); try { QueueBrowser queueBrowser = session.createBrowser(queue); @SuppressWarnings("unchecked") Enumeration<Message> messages = queueBrowser.getEnumeration(); while (messages.hasMoreElements()) { messages.nextElement(); } } finally { connection.close(); } }
Example #4
Source File: JmsTemplate.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Override public <T> T browseSelected(final String queueName, final String messageSelector, final BrowserCallback<T> action) throws JmsException { Assert.notNull(action, "Callback object must not be null"); return execute(new SessionCallback<T>() { @Override public T doInJms(Session session) throws JMSException { Queue queue = (Queue) getDestinationResolver().resolveDestinationName(session, queueName, false); QueueBrowser browser = createBrowser(session, queue, messageSelector); try { return action.doInJms(session, browser); } finally { JmsUtils.closeQueueBrowser(browser); } } }, true); }
Example #5
Source File: JMSUsecaseTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
@Test public void testQueueBrowser() throws Exception { // Send a message to the broker. connection.start(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); ActiveMQDestination destination = createDestination(session, destinationType); MessageProducer producer = session.createProducer(destination); producer.setDeliveryMode(this.deliveryMode); sendMessages(session, producer, 5); producer.close(); QueueBrowser browser = session.createBrowser((Queue) destination); Enumeration<?> enumeration = browser.getEnumeration(); for (int i = 0; i < 5; i++) { Thread.sleep(100); assertTrue(enumeration.hasMoreElements()); Message m = (Message) enumeration.nextElement(); assertNotNull(m); assertEquals("" + i, ((TextMessage) m).getText()); } assertFalse(enumeration.hasMoreElements()); }
Example #6
Source File: JMSTransactionTest.java From cxf with Apache License 2.0 | 6 votes |
private static void assertNumMessagesInQueue(String message, Connection connection, Queue queue, int expectedNum, int timeout) throws JMSException, InterruptedException { Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); QueueBrowser browser = session.createBrowser(queue); int actualNum = 0; for (long startTime = System.currentTimeMillis(); System.currentTimeMillis() - startTime < timeout; Thread.sleep(100L)) { actualNum = 0; for (Enumeration<?> messages = browser.getEnumeration(); messages.hasMoreElements(); actualNum++) { messages.nextElement(); } if (actualNum == expectedNum) { break; } //System.out.println("Messages in queue " + queue.getQueueName() + ": " + actualNum // + ", expecting: " + expectedNum); } browser.close(); session.close(); Assert.assertEquals(message + " -> number of messages", expectedNum, actualNum); }
Example #7
Source File: JmsTemplate.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Override public <T> T browseSelected(final Queue queue, final String messageSelector, final BrowserCallback<T> action) throws JmsException { Assert.notNull(action, "Callback object must not be null"); return execute(new SessionCallback<T>() { @Override public T doInJms(Session session) throws JMSException { QueueBrowser browser = createBrowser(session, queue, messageSelector); try { return action.doInJms(session, browser); } finally { JmsUtils.closeQueueBrowser(browser); } } }, true); }
Example #8
Source File: JmsQueueBrowserTest.java From pooled-jms with Apache License 2.0 | 6 votes |
@Test public void testGetQueue() throws JMSException { JmsPoolConnection connection = (JmsPoolConnection) cf.createQueueConnection(); QueueSession session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); Queue queue = session.createTemporaryQueue(); QueueBrowser browser = session.createBrowser(queue); assertNotNull(browser.getQueue()); browser.close(); browser.close(); try { browser.getQueue(); fail("Should not be able to use a closed browser"); } catch (IllegalStateException ise) { } }
Example #9
Source File: ActiveMQRASession.java From activemq-artemis with Apache License 2.0 | 6 votes |
/** * Create a browser * * @param queue The queue * @param messageSelector The message selector * @return The browser * @throws JMSException Thrown if an error occurs */ @Override public QueueBrowser createBrowser(final Queue queue, final String messageSelector) throws JMSException { if (cri.getType() == ActiveMQRAConnectionFactory.TOPIC_CONNECTION || cri.getType() == ActiveMQRAConnectionFactory.XA_TOPIC_CONNECTION) { throw new IllegalStateException("Cannot create browser for javax.jms.TopicSession"); } Session session = getSessionInternal(); if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("createBrowser " + session + " queue=" + queue + " selector=" + messageSelector); } QueueBrowser result = session.createBrowser(queue, messageSelector); if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("createdBrowser " + session + " browser=" + result); } return result; }
Example #10
Source File: JmsQueueBrowserTest.java From pooled-jms with Apache License 2.0 | 6 votes |
@Test public void testGetEnumeration() throws JMSException { JmsPoolConnection connection = (JmsPoolConnection) cf.createQueueConnection(); QueueSession session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); Queue queue = session.createTemporaryQueue(); QueueBrowser browser = session.createBrowser(queue); assertNotNull(browser.getEnumeration()); browser.close(); try { browser.getEnumeration(); fail("Should not be able to use a closed browser"); } catch (IllegalStateException ise) { } }
Example #11
Source File: JMSUsecaseTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
public void testQueueBrowser() throws Exception { // Send a message to the broker. connection.start(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); destination = createDestination(session, destinationType); MessageProducer producer = session.createProducer(destination); producer.setDeliveryMode(this.deliveryMode); sendMessages(session, producer, 5); producer.close(); QueueBrowser browser = session.createBrowser((Queue) destination); Enumeration<?> enumeration = browser.getEnumeration(); for (int i = 0; i < 5; i++) { Thread.sleep(100); assertTrue(enumeration.hasMoreElements()); Message m = (Message) enumeration.nextElement(); assertNotNull(m); assertEquals("" + i, ((TextMessage) m).getText()); } assertFalse(enumeration.hasMoreElements()); }
Example #12
Source File: JMSQueueBrowserTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
@Test(timeout = 40000) public void testNoMessagesBrowserHasNoElements() throws Exception { Connection connection = createConnection(); connection.start(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); assertNotNull(session); javax.jms.Queue queue = session.createQueue(getQueueName()); session.createConsumer(queue).close(); QueueBrowser browser = session.createBrowser(queue); assertNotNull(browser); Queue queueView = getProxyToQueue(getQueueName()); assertEquals(0, queueView.getMessageCount()); Enumeration<?> enumeration = browser.getEnumeration(); assertFalse(enumeration.hasMoreElements()); }
Example #13
Source File: JmsQueueBrowserTest.java From qpid-jms with Apache License 2.0 | 6 votes |
@Test(timeout=30000) public void testBroseOneInQueue() throws Exception { connection = createAmqpConnection(); connection.start(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); Queue queue = session.createQueue(getDestinationName()); MessageProducer producer = session.createProducer(queue); producer.send(session.createTextMessage("hello")); producer.close(); QueueBrowser browser = session.createBrowser(queue); Enumeration enumeration = browser.getEnumeration(); while (enumeration.hasMoreElements()) { Message m = (Message) enumeration.nextElement(); assertTrue(m instanceof TextMessage); LOG.debug("Browsed message {} from Queue {}", m, queue); } browser.close(); MessageConsumer consumer = session.createConsumer(queue); Message msg = consumer.receive(5000); assertNotNull(msg); assertTrue(msg instanceof TextMessage); }
Example #14
Source File: JMSQueueBrowserTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
@Test(timeout = 30000) public void testBroseOneInQueue() throws Exception { Connection connection = createConnection(); connection.start(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); javax.jms.Queue queue = session.createQueue(getQueueName()); MessageProducer producer = session.createProducer(queue); producer.send(session.createTextMessage("hello")); producer.close(); QueueBrowser browser = session.createBrowser(queue); Enumeration<?> enumeration = browser.getEnumeration(); while (enumeration.hasMoreElements()) { Message m = (Message) enumeration.nextElement(); assertTrue(m instanceof TextMessage); LOG.debug("Browsed message {} from Queue {}", m, queue); } browser.close(); MessageConsumer consumer = session.createConsumer(queue); Message msg = consumer.receive(5000); assertNotNull(msg); assertTrue(msg instanceof TextMessage); }
Example #15
Source File: JMSQueueBrowserTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
@Test(timeout = 60000) public void testBrowseAllInQueuePrefetchOne() throws Exception { Connection connection = createConnection(); connection.start(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); assertNotNull(session); javax.jms.Queue queue = session.createQueue(getQueueName()); sendMessages(name.getMethodName(), 5, false); Queue queueView = getProxyToQueue(getQueueName()); Wait.assertEquals(5, queueView::getMessageCount); QueueBrowser browser = session.createBrowser(queue); assertNotNull(browser); Enumeration<?> enumeration = browser.getEnumeration(); int count = 0; while (enumeration.hasMoreElements()) { Message msg = (Message) enumeration.nextElement(); assertNotNull(msg); LOG.debug("Recv: {}", msg); count++; } assertFalse(enumeration.hasMoreElements()); assertEquals(5, count); }
Example #16
Source File: BrowserTest.java From qpid-broker-j with Apache License 2.0 | 6 votes |
@Test public void stoppedConnection() throws Exception { Queue queue = createQueue(getTestName()); Connection connection = getConnection(); try { Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); QueueBrowser browser = session.createBrowser(queue); try { browser.getEnumeration(); // PASS } catch (IllegalStateException e) { //PASS } } finally { connection.close(); } }
Example #17
Source File: JmsTemplate.java From java-technology-stack with MIT License | 6 votes |
@Override @Nullable public <T> T browseSelected(final Queue queue, @Nullable final String messageSelector, final BrowserCallback<T> action) throws JmsException { Assert.notNull(action, "Callback object must not be null"); return execute(session -> { QueueBrowser browser = createBrowser(session, queue, messageSelector); try { return action.doInJms(session, browser); } finally { JmsUtils.closeQueueBrowser(browser); } }, true); }
Example #18
Source File: SecurityJMXTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
public void testBrowseExpiredMessages() throws Exception { JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:1199/jmxrmi"); JMXConnector connector = JMXConnectorFactory.connect(url, null); connector.connect(); MBeanServerConnection connection = connector.getMBeanServerConnection(); ObjectName name = new ObjectName("org.apache.activemq:type=Broker,brokerName=localhost," + "destinationType=Queue,destinationName=TEST.Q"); QueueViewMBean queueMbean = MBeanServerInvocationHandler.newProxyInstance(connection, name, QueueViewMBean.class, true); HashMap<String, String> headers = new HashMap<>(); headers.put("timeToLive", Long.toString(2000)); headers.put("JMSDeliveryMode", Integer.toString(DeliveryMode.PERSISTENT)); queueMbean.sendTextMessage(headers, "test", "system", "manager"); // allow message to expire on the queue TimeUnit.SECONDS.sleep(4); Connection c = new ActiveMQConnectionFactory("vm://localhost").createConnection("system", "manager"); c.start(); // browser consumer will force expiration check on addConsumer QueueBrowser browser = c.createSession(false, Session.AUTO_ACKNOWLEDGE).createBrowser(new ActiveMQQueue("TEST.Q")); assertTrue("no message in the q", !browser.getEnumeration().hasMoreElements()); // verify dlq got the message, no security exception as brokers context is now used browser = c.createSession(false, Session.AUTO_ACKNOWLEDGE).createBrowser(new ActiveMQQueue("ActiveMQ.DLQ")); assertTrue("one message in the dlq", browser.getEnumeration().hasMoreElements()); }
Example #19
Source File: MessageListenerTest.java From cxf with Apache License 2.0 | 6 votes |
private static void assertNumMessagesInQueue(String message, Connection connection, Queue queue, int expectedNum, long timeout) throws JMSException, InterruptedException { Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); QueueBrowser browser = session.createBrowser(queue); int actualNum = 0; for (long startTime = System.currentTimeMillis(); System.currentTimeMillis() - startTime < timeout; Thread.sleep(100L)) { actualNum = 0; for (Enumeration<?> messages = browser.getEnumeration(); messages.hasMoreElements(); actualNum++) { messages.nextElement(); } if (actualNum == expectedNum) { break; } //System.out.println("Messages in queue " + queue.getQueueName() + ": " + actualNum // + ", expecting: " + expectedNum); } browser.close(); session.close(); assertEquals(message + " -> number of messages on queue", expectedNum, actualNum); }
Example #20
Source File: JmsQueueBrowserTest.java From qpid-jms with Apache License 2.0 | 5 votes |
@Test(timeout = 40000) public void testBrowseAllInQueuePrefetchOne() throws Exception { connection = createAmqpConnection(); JmsConnection jmsConnection = (JmsConnection) connection; ((JmsDefaultPrefetchPolicy) jmsConnection.getPrefetchPolicy()).setQueueBrowserPrefetch(1); connection.start(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); assertNotNull(session); Queue queue = session.createQueue(getDestinationName()); sendToAmqQueue(5); QueueViewMBean proxy = getProxyToQueue(getDestinationName()); assertEquals(5, proxy.getQueueSize()); QueueBrowser browser = session.createBrowser(queue); assertNotNull(browser); Enumeration enumeration = browser.getEnumeration(); int count = 0; while (enumeration.hasMoreElements()) { Message msg = (Message) enumeration.nextElement(); assertNotNull(msg); LOG.debug("Recv: {}", msg); count++; } assertFalse(enumeration.hasMoreElements()); assertEquals(5, count); }
Example #21
Source File: QueueBrowserIntegrationTest.java From qpid-jms with Apache License 2.0 | 5 votes |
@Test(timeout=30000) public void testQueueBrowserPrefetchOne() throws IOException, Exception { final DescribedType amqpValueNullContent = new AmqpValueDescribedType(null); try (TestAmqpPeer testPeer = new TestAmqpPeer();) { Connection connection = testFixture.establishConnecton(testPeer, "?jms.prefetchPolicy.all=1"); connection.start(); testPeer.expectBegin(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); Queue queue = session.createQueue("myQueue"); // Expected the browser to create a consumer and send credit, then drain it when // no message arrives before hasMoreElements is called, at which point we send one. testPeer.expectQueueBrowserAttach(); testPeer.expectLinkFlow(false, equalTo(UnsignedInteger.ONE)); testPeer.expectLinkFlowRespondWithTransfer(null, null, null, null, amqpValueNullContent, 1, true, true, Matchers.equalTo(UnsignedInteger.ONE), 1, true, false); testPeer.expectLinkFlow(false, equalTo(UnsignedInteger.ONE)); testPeer.expectDetach(true, true, true); QueueBrowser browser = session.createBrowser(queue); Enumeration<?> queueView = browser.getEnumeration(); assertNotNull(queueView); assertTrue(queueView.hasMoreElements()); assertNotNull(queueView.nextElement()); browser.close(); testPeer.expectClose(); connection.close(); testPeer.waitForAllHandlersToComplete(3000); } }
Example #22
Source File: QueueBrowserIntegrationTest.java From qpid-jms with Apache License 2.0 | 5 votes |
@Test(timeout=30000) public void testCreateQueueBrowserAndEnumeration() throws IOException, Exception { try (TestAmqpPeer testPeer = new TestAmqpPeer();) { Connection connection = testFixture.establishConnecton(testPeer); connection.start(); testPeer.expectBegin(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); Queue queue = session.createQueue("myQueue"); // Expected the browser to create a consumer and send credit. testPeer.expectQueueBrowserAttach(); testPeer.expectLinkFlow(false, equalTo(UnsignedInteger.valueOf(JmsDefaultPrefetchPolicy.DEFAULT_QUEUE_BROWSER_PREFETCH))); testPeer.expectDetach(true, true, true); QueueBrowser browser = session.createBrowser(queue); Enumeration<?> queueView = browser.getEnumeration(); assertNotNull(queueView); browser.close(); testPeer.expectClose(); connection.close(); testPeer.waitForAllHandlersToComplete(3000); } }
Example #23
Source File: JMSSenderBean.java From tomee with Apache License 2.0 | 5 votes |
public int countMessagesInQueue(final String queueName) throws Exception { final Queue queue = jmsContext.createQueue(queueName); final QueueBrowser browser = jmsContext.createBrowser(queue); final Enumeration<?> msgEnumeration = browser.getEnumeration(); int count = 0; while (msgEnumeration.hasMoreElements()) { msgEnumeration.nextElement(); count++; } return count; }
Example #24
Source File: JMSQueueBrowserTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Test(timeout = 60000) public void testBrowseAllInQueue() throws Exception { Connection connection = createConnection(); connection.start(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); assertNotNull(session); javax.jms.Queue queue = session.createQueue(getQueueName()); sendMessages(name.getMethodName(), 5, false); Queue queueView = getProxyToQueue(getQueueName()); Wait.assertEquals(5, queueView::getMessageCount); QueueBrowser browser = session.createBrowser(queue); assertNotNull(browser); Enumeration<?> enumeration = browser.getEnumeration(); int count = 0; while (enumeration.hasMoreElements()) { Message msg = (Message) enumeration.nextElement(); assertNotNull(msg); LOG.debug("Recv: {}", msg); count++; TimeUnit.MILLISECONDS.sleep(50); } assertFalse(enumeration.hasMoreElements()); assertEquals(5, count); }
Example #25
Source File: JMSQueueBrowserTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Test(timeout = 60000) public void testBrowseAllInQueueSmallPrefetch() throws Exception { Connection connection = createConnection(); connection.start(); final int MSG_COUNT = 30; Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); assertNotNull(session); javax.jms.Queue queue = session.createQueue(getQueueName()); sendMessages(name.getMethodName(), MSG_COUNT, false); Queue queueView = getProxyToQueue(getQueueName()); Wait.assertEquals(MSG_COUNT, queueView::getMessageCount); QueueBrowser browser = session.createBrowser(queue); assertNotNull(browser); Enumeration<?> enumeration = browser.getEnumeration(); int count = 0; while (enumeration.hasMoreElements()) { Message msg = (Message) enumeration.nextElement(); assertNotNull(msg); LOG.debug("Recv: {}", msg); count++; } assertFalse(enumeration.hasMoreElements()); assertEquals(MSG_COUNT, count); }
Example #26
Source File: PurgeCommandTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
public void testPurgeCommandComplexSQLSelector_OR() throws Exception { try { PurgeCommand purgeCommand = new PurgeCommand(); CommandContext context = new CommandContext(); context.setFormatter(new CommandShellOutputFormatter(System.out)); purgeCommand.setCommandContext(context); purgeCommand.setJmxUseLocal(true); List<String> tokens = new ArrayList<>(); tokens.add("--msgsel"); tokens.add(MSG_SEL_COMPLEX_SQL_OR); addMessages(); validateCounts(MESSAGE_COUNT, MESSAGE_COUNT, MESSAGE_COUNT * 2); purgeCommand.execute(tokens); QueueBrowser withPropertyBrowser = requestServerSession.createBrowser(theQueue, MSG_SEL_COMPLEX_SQL_OR); QueueBrowser allBrowser = requestServerSession.createBrowser(theQueue); int withCount = getMessageCount(withPropertyBrowser, "withProperty "); int allCount = getMessageCount(allBrowser, "allMessages "); withPropertyBrowser.close(); allBrowser.close(); assertEquals("Expected withCount to be 0 but was " + withCount, 0, withCount); assertEquals("Expected allCount to be 0 but was " + allCount, 0, allCount); LOG.info("withCount = " + withCount + "\n allCount = " + allCount + "\n = " + "\n"); } finally { purgeAllMessages(); } }
Example #27
Source File: PurgeCommandTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
public int getMessageCount(QueueBrowser browser, String prefix) throws JMSException { Enumeration<?> e = browser.getEnumeration(); int with = 0; while (e.hasMoreElements()) { Object o = e.nextElement(); System.out.println(prefix + o); with++; } return with; }
Example #28
Source File: JmsContext.java From qpid-jms with Apache License 2.0 | 5 votes |
private QueueBrowser startIfNeeded(QueueBrowser browser) throws JMSException { if (getAutoStart()) { connection.start(); } return browser; }
Example #29
Source File: BrowserTest.java From qpid-broker-j with Apache License 2.0 | 5 votes |
@Test public void browserIsNonDestructive() throws Exception { Queue queue = createQueue(getTestName()); Connection connection = getConnection(); try { connection.start(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); MessageProducer producer = session.createProducer(queue); final Message message = session.createMessage(); producer.send(message); producer.close(); QueueBrowser browser = session.createBrowser(queue); Enumeration enumeration = browser.getEnumeration(); assertTrue("Unexpected browser state", enumeration.hasMoreElements()); Message browsedMessage = (Message) enumeration.nextElement(); assertNotNull("No message returned by browser", browsedMessage); assertEquals("Unexpected JMSMessageID on browsed message", message.getJMSMessageID(), browsedMessage.getJMSMessageID()); browser.close(); MessageConsumer consumer = session.createConsumer(queue); Message consumedMessage = consumer.receive(getReceiveTimeout()); assertNotNull("No message returned by consumer", consumedMessage); assertEquals("Unexpected JMSMessageID on consumed message", message.getJMSMessageID(), consumedMessage.getJMSMessageID()); QueueBrowser browser2 = session.createBrowser(queue); Enumeration enumeration2 = browser2.getEnumeration(); assertFalse("Unexpected browser state", enumeration2.hasMoreElements()); browser2.close(); } finally { connection.close(); } }
Example #30
Source File: JMSContextImpl.java From tomee with Apache License 2.0 | 5 votes |
@Override public QueueBrowser createBrowser(final Queue queue, final String messageSelector) { try { final QueueBrowser browser = session().createBrowser(queue, messageSelector); checkAutoStart(); return browser; } catch (final JMSException e) { throw toRuntimeException(e); } }