List of usage examples for javax.jms Session createSharedConsumer
MessageConsumer createSharedConsumer(Topic topic, String sharedSubscriptionName) throws JMSException;
From source file:org.apache.activemq.artemis.tests.integration.persistence.metrics.JournalPendingMessageTest.java
@Test public void testTopicMessageSizeShared() throws Exception { AtomicLong publishedMessageSize = new AtomicLong(); Connection connection = cf.createConnection(); connection.setClientID("clientId"); connection.start();// w w w . j a v a 2 s . c o m Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); MessageConsumer consumer = session.createSharedConsumer(session.createTopic(defaultTopicName), "sub1"); MessageConsumer consumer2 = session.createSharedConsumer(session.createTopic(defaultTopicName), "sub1"); publishTestTopicMessages(200, publishedMessageSize); verifyPendingStats(defaultTopicName, 200, publishedMessageSize.get()); verifyPendingDurableStats(defaultTopicName, 0, 0); consumer2.close(); // consume all messages consumeTestMessages(consumer, 200); // All messages should now be gone verifyPendingStats(defaultTopicName, 0, 0); verifyPendingDurableStats(defaultTopicName, 0, 0); connection.close(); }