List of usage examples for javax.jms Session createSharedDurableConsumer
MessageConsumer createSharedDurableConsumer(Topic topic, String name) throws JMSException;
From source file:org.apache.activemq.artemis.tests.integration.persistence.metrics.JournalPendingMessageTest.java
@Test public void testMessageSizeSharedDurable() throws Exception { AtomicLong publishedMessageSize = new AtomicLong(); Connection connection = cf.createConnection(); connection.setClientID("clientId"); connection.start();// ww w .ja v a 2s.c o m // The publish method will create a second shared consumer Session s = connection.createSession(); MessageConsumer c = s.createSharedDurableConsumer(s.createTopic(defaultTopicName), "sub1"); publishTestMessagesDurable(connection, new String[] { "sub1", }, 200, publishedMessageSize, DeliveryMode.PERSISTENT, true); // verify the count and size - double because two durables so two queue // bindings verifyPendingStats(defaultTopicName, 200, publishedMessageSize.get()); verifyPendingDurableStats(defaultTopicName, 200, publishedMessageSize.get()); c.close(); // consume messages for sub1 consumeDurableTestMessages(connection, "sub1", 200, publishedMessageSize); verifyPendingStats(defaultTopicName, 0, publishedMessageSize.get()); verifyPendingDurableStats(defaultTopicName, 0, publishedMessageSize.get()); connection.close(); }