Here are the examples of the java api class org.apache.activemq.command.ActiveMQTopic taken from open source projects.
1. TopicBridgeStandaloneReconnectTest#setUp()
Project: activemq-artemis
File: TopicBridgeStandaloneReconnectTest.java
File: TopicBridgeStandaloneReconnectTest.java
@Before public void setUp() throws Exception { localConnectionFactory = createLocalConnectionFactory(); foreignConnectionFactory = createForeignConnectionFactory(); outbound = new ActiveMQTopic("RECONNECT.TEST.OUT.TOPIC"); inbound = new ActiveMQTopic("RECONNECT.TEST.IN.TOPIC"); jmsTopicConnector = new SimpleJmsTopicConnector(); // Wire the bridges. jmsTopicConnector.setOutboundTopicBridges(new OutboundTopicBridge[] { new OutboundTopicBridge("RECONNECT.TEST.OUT.TOPIC") }); jmsTopicConnector.setInboundTopicBridges(new InboundTopicBridge[] { new InboundTopicBridge("RECONNECT.TEST.IN.TOPIC") }); // Tell it how to reach the two brokers. jmsTopicConnector.setOutboundTopicConnectionFactory(new ActiveMQConnectionFactory("tcp://localhost:61617")); jmsTopicConnector.setLocalTopicConnectionFactory(new ActiveMQConnectionFactory("tcp://localhost:61616")); }
2. TopicSubscriptionZeroPrefetchTest#testDurableTopicConsumerPrefetchZero()
Project: activemq-artemis
File: TopicSubscriptionZeroPrefetchTest.java
File: TopicSubscriptionZeroPrefetchTest.java
/* * test durable topic subscription with prefetch zero */ @Test(timeout = 60000) public void testDurableTopicConsumerPrefetchZero() throws Exception { ActiveMQTopic consumerDestination = new ActiveMQTopic(TOPIC_NAME + "?consumer.prefetchSize=0"); consumer = session.createDurableSubscriber(consumerDestination, "mysub1"); // publish messages Message txtMessage = session.createTextMessage("M"); producer.send(txtMessage); Message consumedMessage = consumer.receive(100); Assert.assertNotNull("should have received a message the published message", consumedMessage); }
3. TopicSubscriptionZeroPrefetchTest#testTopicConsumerPrefetchZero()
Project: activemq-artemis
File: TopicSubscriptionZeroPrefetchTest.java
File: TopicSubscriptionZeroPrefetchTest.java
/* * test non durable topic subscription with prefetch set to zero */ @Test(timeout = 60000) public void testTopicConsumerPrefetchZero() throws Exception { ActiveMQTopic consumerDestination = new ActiveMQTopic(TOPIC_NAME + "?consumer.retroactive=true&consumer.prefetchSize=0"); consumer = session.createConsumer(consumerDestination); // publish messages Message txtMessage = session.createTextMessage("M"); producer.send(txtMessage); Message consumedMessage = consumer.receiveNoWait(); Assert.assertNotNull("should have received a message the published message", consumedMessage); }
4. TopicSubscriptionZeroPrefetchTest#setUp()
Project: activemq-artemis
File: TopicSubscriptionZeroPrefetchTest.java
File: TopicSubscriptionZeroPrefetchTest.java
@Before public void setUp() throws Exception { brokerService = createBroker(); ActiveMQConnectionFactory activeMQConnectionFactory = new ActiveMQConnectionFactory("vm://localhost"); activeMQConnectionFactory.setWatchTopicAdvisories(true); connection = activeMQConnectionFactory.createConnection(); connection.setClientID("ClientID-1"); session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); destination = new ActiveMQTopic(TOPIC_NAME); producer = session.createProducer(destination); connection.start(); }
5. TopicSubscriptionSlowConsumerTest#setUp()
Project: activemq-artemis
File: TopicSubscriptionSlowConsumerTest.java
File: TopicSubscriptionSlowConsumerTest.java
@Override public void setUp() throws Exception { brokerService = createBroker(); ActiveMQConnectionFactory activeMQConnectionFactory = new ActiveMQConnectionFactory("vm://localhost"); activeMQConnectionFactory.setWatchTopicAdvisories(true); connection = activeMQConnectionFactory.createConnection(); session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); destination = new ActiveMQTopic(TOPIC_NAME); producer = session.createProducer(destination); connection.start(); }
6. NetworkBrokerDetachTest#registerDurableConsumer()
Project: activemq-artemis
File: NetworkBrokerDetachTest.java
File: NetworkBrokerDetachTest.java
private ActiveMQTopic registerDurableConsumer(BrokerService brokerService, MessageListener listener) throws Exception { ConnectionFactory factory = createConnectionFactory(brokerService); Connection connection = factory.createConnection(); connection.setClientID("DurableOne"); connection.start(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); ActiveMQTopic destination = (ActiveMQTopic) session.createTopic(DESTINATION_NAME); // unique to a broker TopicSubscriber sub = session.createDurableSubscriber(destination, "SubOne" + brokerService.getBrokerName()); sub.setMessageListener(listener); return destination; }
7. CompressionOverNetworkTest#doSetUp()
Project: activemq-artemis
File: CompressionOverNetworkTest.java
File: CompressionOverNetworkTest.java
protected void doSetUp(boolean deleteAllMessages) throws Exception { localBroker = createLocalBroker(); localBroker.setDeleteAllMessagesOnStartup(deleteAllMessages); localBroker.start(); localBroker.waitUntilStarted(); remoteBroker = createRemoteBroker(); remoteBroker.setDeleteAllMessagesOnStartup(deleteAllMessages); remoteBroker.start(); remoteBroker.waitUntilStarted(); URI localURI = localBroker.getVmConnectorURI(); ActiveMQConnectionFactory fac = new ActiveMQConnectionFactory(localURI); fac.setAlwaysSyncSend(true); fac.setDispatchAsync(false); localConnection = fac.createConnection(); localConnection.setClientID("clientId"); localConnection.start(); URI remoteURI = remoteBroker.getVmConnectorURI(); fac = new ActiveMQConnectionFactory(remoteURI); remoteConnection = fac.createConnection(); remoteConnection.setClientID("clientId"); remoteConnection.start(); included = new ActiveMQTopic("include.test.bar"); localSession = localConnection.createSession(false, Session.AUTO_ACKNOWLEDGE); remoteSession = remoteConnection.createSession(false, Session.AUTO_ACKNOWLEDGE); }
8. ActiveMQInitialContextFactoryTest#testDynamicallyGrowing()
Project: activemq-artemis
File: ActiveMQInitialContextFactoryTest.java
File: ActiveMQInitialContextFactoryTest.java
public void testDynamicallyGrowing() throws Exception { Object answer = context.lookup("dynamicQueues/FOO.BAR"); assertTrue("Should have found a queue but found: " + answer, answer instanceof ActiveMQQueue); ActiveMQQueue queue = (ActiveMQQueue) answer; assertEquals("queue name", "FOO.BAR", queue.getPhysicalName()); answer = context.lookup("dynamicTopics/A.B.C"); assertTrue("Should have found a topic but found: " + answer, answer instanceof ActiveMQTopic); ActiveMQTopic topic = (ActiveMQTopic) answer; assertEquals("topic name", "A.B.C", topic.getPhysicalName()); }
9. TopicSubscriptionSlowConsumerTest#testPrefetchValueOne()
Project: activemq-artemis
File: TopicSubscriptionSlowConsumerTest.java
File: TopicSubscriptionSlowConsumerTest.java
public void testPrefetchValueOne() throws Exception { ActiveMQTopic consumerDestination = new ActiveMQTopic(TOPIC_NAME + "?consumer.prefetchSize=1"); consumer = session.createConsumer(consumerDestination); //add a consumer to the slow consumer advisory topic. ActiveMQTopic slowConsumerAdvisoryTopic = AdvisorySupport.getSlowConsumerAdvisoryTopic(destination); MessageConsumer slowConsumerAdvisory = session.createConsumer(slowConsumerAdvisoryTopic); //publish 2 messages Message txtMessage = session.createTextMessage("Sample Text Message"); for (int i = 0; i < 2; i++) { producer.send(txtMessage); } //consume 2 messages for (int i = 0; i < 2; i++) { Message receivedMsg = consumer.receive(100); Assert.assertNotNull("received msg " + i + " should not be null", receivedMsg); } //check for "slow consumer" advisory message Message slowAdvisoryMessage = slowConsumerAdvisory.receive(100); Assert.assertNull("should not have received a slow consumer advisory message", slowAdvisoryMessage); }
10. NetworkBridgeProducerFlowControlTest#testSendFailIfNoSpaceDoesNotBlockTopicNetwork()
Project: activemq-artemis
File: NetworkBridgeProducerFlowControlTest.java
File: NetworkBridgeProducerFlowControlTest.java
public void testSendFailIfNoSpaceDoesNotBlockTopicNetwork() throws Exception { // Consumer prefetch is disabled for broker1's consumers. final ActiveMQTopic SLOW_SHARED_TOPIC = new ActiveMQTopic(NetworkBridgeProducerFlowControlTest.class.getSimpleName() + ".slow.shared?consumer.prefetchSize=1"); final ActiveMQTopic FAST_SHARED_TOPIC = new ActiveMQTopic(NetworkBridgeProducerFlowControlTest.class.getSimpleName() + ".fast.shared?consumer.prefetchSize=1"); doTestSendFailIfNoSpaceDoesNotBlockNetwork(SLOW_SHARED_TOPIC, FAST_SHARED_TOPIC); }
11. SimpleNetworkTest#doSetUp()
Project: activemq-artemis
File: SimpleNetworkTest.java
File: SimpleNetworkTest.java
protected void doSetUp(boolean deleteAllMessages) throws Exception { remoteBroker = createRemoteBroker(); remoteBroker.setDeleteAllMessagesOnStartup(deleteAllMessages); remoteBroker.start(); remoteBroker.waitUntilStarted(); localBroker = createLocalBroker(); localBroker.setDeleteAllMessagesOnStartup(deleteAllMessages); localBroker.start(); localBroker.waitUntilStarted(); URI localURI = localBroker.getVmConnectorURI(); ActiveMQConnectionFactory fac = new ActiveMQConnectionFactory(localURI); fac.setAlwaysSyncSend(true); fac.setDispatchAsync(false); localConnection = fac.createConnection(); localConnection.setClientID("clientId"); localConnection.start(); URI remoteURI = remoteBroker.getVmConnectorURI(); fac = new ActiveMQConnectionFactory(remoteURI); remoteConnection = fac.createConnection(); remoteConnection.setClientID("clientId"); remoteConnection.start(); included = new ActiveMQTopic("include.test.bar"); excluded = new ActiveMQTopic("exclude.test.bar"); localSession = localConnection.createSession(false, Session.AUTO_ACKNOWLEDGE); remoteSession = remoteConnection.createSession(false, Session.AUTO_ACKNOWLEDGE); }
12. ActiveMQClientITBase#testTopicPush()
Project: pinpoint
File: ActiveMQClientITBase.java
File: ActiveMQClientITBase.java
@Test public void testTopicPush() throws Exception { // Given final String testTopicName = "TestPushTopic"; final ActiveMQTopic testTopic = new ActiveMQTopic(testTopicName); final String testMessage = "Hello World for Topic!"; final int numMessageConsumers = 2; final CountDownLatch consumerConsumeLatch = new CountDownLatch(numMessageConsumers); final Collection<Throwable> consumerThrowables = new CopyOnWriteArrayList<Throwable>(); // create producer ActiveMQSession producerSession = ActiveMQClientITHelper.createSession(getProducerBrokerName(), getProducerBrokerUrl()); MessageProducer producer = new MessageProducerBuilder(producerSession, testTopic).waitTillStarted().build(); final TextMessage expectedTextMessage = producerSession.createTextMessage(testMessage); // create 2 consumers ActiveMQSession consumer1Session = ActiveMQClientITHelper.createSession(getConsumerBrokerName(), getConsumerBrokerUrl()); new MessageConsumerBuilder(consumer1Session, testTopic).withMessageListener(new AssertTextMessageListener(consumerConsumeLatch, consumerThrowables, expectedTextMessage)).waitTillStarted().build(); ActiveMQSession consumer2Session = ActiveMQClientITHelper.createSession(getConsumerBrokerName(), getConsumerBrokerUrl()); new MessageConsumerBuilder(consumer2Session, testTopic).withMessageListener(new AssertTextMessageListener(consumerConsumeLatch, consumerThrowables, expectedTextMessage)).waitTillStarted().build(); // When producer.send(expectedTextMessage); consumerConsumeLatch.await(1L, TimeUnit.SECONDS); // Then // Wait till all traces are recorded (consumer traces are recorded from another thread) awaitAndVerifyTraceCount(3, 1000L); // trace count : 1 verifyProducerSendEvent(testTopic); // trace count : 1 verifyConsumerPushEvent(testTopic); // trace count : 1 verifyConsumerPushEvent(testTopic); }
13. ActiveMQClientITBase#testTopicPull()
Project: pinpoint
File: ActiveMQClientITBase.java
File: ActiveMQClientITBase.java
@Test public void testTopicPull() throws Exception { // Given final String testTopicName = "TestPullTopic"; final ActiveMQTopic testTopic = new ActiveMQTopic(testTopicName); final String testMessage = "Hello World for Topic!"; // create producer ActiveMQSession producerSession = ActiveMQClientITHelper.createSession(getProducerBrokerName(), getProducerBrokerUrl()); MessageProducer producer = new MessageProducerBuilder(producerSession, testTopic).waitTillStarted().build(); final TextMessage expectedTextMessage = producerSession.createTextMessage(testMessage); // create 2 consumers ActiveMQSession consumer1Session = ActiveMQClientITHelper.createSession(getConsumerBrokerName(), getConsumerBrokerUrl()); MessageConsumer consumer1 = new MessageConsumerBuilder(consumer1Session, testTopic).waitTillStarted().build(); ActiveMQSession consumer2Session = ActiveMQClientITHelper.createSession(getConsumerBrokerName(), getConsumerBrokerUrl()); MessageConsumer consumer2 = new MessageConsumerBuilder(consumer2Session, testTopic).waitTillStarted().build(); // When producer.send(expectedTextMessage); Message message1 = consumer1.receive(1000L); Message message2 = consumer2.receive(1000L); Assert.assertEquals(testMessage, ((TextMessage) message1).getText()); Assert.assertEquals(testMessage, ((TextMessage) message2).getText()); // Wait till all traces are recorded (consumer traces are recorded from another thread) awaitAndVerifyTraceCount(9, 5000L); // trace count : 1 verifyProducerSendEvent(testTopic); // trace count : 4 verifyConsumerPullEvent(testTopic, consumer1, expectedTextMessage); // trace count : 4 verifyConsumerPullEvent(testTopic, consumer2, expectedTextMessage); }
14. RedeliveryPolicyTest#testRedeliveryPolicyPerDestination()
Project: activemq-artemis
File: RedeliveryPolicyTest.java
File: RedeliveryPolicyTest.java
@Test public void testRedeliveryPolicyPerDestination() throws Exception { RedeliveryPolicy queuePolicy = new RedeliveryPolicy(); queuePolicy.setInitialRedeliveryDelay(0); queuePolicy.setRedeliveryDelay(1000); queuePolicy.setUseExponentialBackOff(false); queuePolicy.setMaximumRedeliveries(2); RedeliveryPolicy topicPolicy = new RedeliveryPolicy(); topicPolicy.setInitialRedeliveryDelay(0); topicPolicy.setRedeliveryDelay(1000); topicPolicy.setUseExponentialBackOff(false); topicPolicy.setMaximumRedeliveries(3); // Receive a message with the JMS API RedeliveryPolicyMap map = connection.getRedeliveryPolicyMap(); map.put(new ActiveMQTopic(">"), topicPolicy); map.put(new ActiveMQQueue(">"), queuePolicy); connection.start(); Session session = connection.createSession(true, Session.AUTO_ACKNOWLEDGE); ActiveMQQueue queue = new ActiveMQQueue("TEST"); ActiveMQTopic topic = new ActiveMQTopic("TEST"); this.makeSureCoreQueueExist("TEST"); MessageProducer producer = session.createProducer(null); MessageConsumer queueConsumer = session.createConsumer(queue); MessageConsumer topicConsumer = session.createConsumer(topic); // Send the messages producer.send(queue, session.createTextMessage("1st")); producer.send(queue, session.createTextMessage("2nd")); producer.send(topic, session.createTextMessage("1st")); producer.send(topic, session.createTextMessage("2nd")); session.commit(); TextMessage m; m = (TextMessage) queueConsumer.receive(100); assertNotNull(m); assertEquals("1st", m.getText()); m = (TextMessage) topicConsumer.receive(100); assertNotNull(m); assertEquals("1st", m.getText()); m = (TextMessage) queueConsumer.receive(100); assertNotNull(m); assertEquals("2nd", m.getText()); m = (TextMessage) topicConsumer.receive(100); assertNotNull(m); assertEquals("2nd", m.getText()); session.rollback(); m = (TextMessage) queueConsumer.receive(100); assertNotNull("first immediate redelivery", m); m = (TextMessage) topicConsumer.receive(100); assertNotNull("first immediate redelivery", m); session.rollback(); m = (TextMessage) queueConsumer.receive(100); assertNull("second delivery delayed: " + m, m); m = (TextMessage) topicConsumer.receive(100); assertNull("second delivery delayed: " + m, m); m = (TextMessage) queueConsumer.receive(2000); assertNotNull(m); assertEquals("1st", m.getText()); m = (TextMessage) topicConsumer.receive(2000); assertNotNull(m); assertEquals("1st", m.getText()); m = (TextMessage) queueConsumer.receive(100); assertNotNull(m); assertEquals("2nd", m.getText()); m = (TextMessage) topicConsumer.receive(100); assertNotNull(m); assertEquals("2nd", m.getText()); session.rollback(); m = (TextMessage) queueConsumer.receive(2000); assertNotNull(m); assertEquals("1st", m.getText()); m = (TextMessage) topicConsumer.receive(2000); assertNotNull(m); assertEquals("1st", m.getText()); m = (TextMessage) queueConsumer.receive(100); assertNotNull(m); assertEquals("2nd", m.getText()); m = (TextMessage) topicConsumer.receive(100); assertNotNull(m); assertEquals("2nd", m.getText()); session.rollback(); // No third attempt for the Queue consumer m = (TextMessage) queueConsumer.receive(2000); assertNull(m); m = (TextMessage) topicConsumer.receive(2000); assertNotNull(m); assertEquals("1st", m.getText()); m = (TextMessage) queueConsumer.receive(100); assertNull(m); m = (TextMessage) topicConsumer.receive(100); assertNotNull(m); assertEquals("2nd", m.getText()); session.commit(); }
15. TwoBrokerVirtualTopicForwardingTest#testDontBridgeQueuesWithBothTypesConsumers()
Project: activemq-artemis
File: TwoBrokerVirtualTopicForwardingTest.java
File: TwoBrokerVirtualTopicForwardingTest.java
public void testDontBridgeQueuesWithBothTypesConsumers() throws Exception { dontBridgeVirtualTopicConsumerQueues("BrokerA", "BrokerB"); startAllBrokers(); waitForBridgeFormation(); MessageConsumer clientA = createConsumer("BrokerA", createDestination("Consumer.A.VirtualTopic.tempTopic", false)); MessageConsumer clientB = createConsumer("BrokerB", createDestination("Consumer.B.VirtualTopic.tempTopic", false)); MessageConsumer clientC = createConsumer("BrokerB", createDestination("VirtualTopic.tempTopic", true)); // give a sec to let advisories propagate Thread.sleep(500); ActiveMQQueue queueA = new ActiveMQQueue("Consumer.A.VirtualTopic.tempTopic"); Destination destination = getDestination(brokers.get("BrokerA").broker, queueA); assertEquals(1, destination.getConsumers().size()); ActiveMQQueue queueB = new ActiveMQQueue("Consumer.B.VirtualTopic.tempTopic"); destination = getDestination(brokers.get("BrokerA").broker, queueB); assertNull(destination); ActiveMQTopic virtualTopic = new ActiveMQTopic("VirtualTopic.tempTopic"); assertNotNull(getDestination(brokers.get("BrokerA").broker, virtualTopic)); assertNotNull(getDestination(brokers.get("BrokerB").broker, virtualTopic)); // send some messages sendMessages("BrokerA", virtualTopic, 1); MessageIdList msgsA = getConsumerMessages("BrokerA", clientA); MessageIdList msgsB = getConsumerMessages("BrokerB", clientB); msgsA.waitForMessagesToArrive(1); msgsB.waitForMessagesToArrive(1); // ensure we don't get any more messages Thread.sleep(2000); assertEquals(1, msgsA.getMessageCount()); assertEquals(1, msgsB.getMessageCount()); }
16. TwoBrokerVirtualTopicForwardingTest#testDontBridgeQueuesWithOnlyQueueConsumers()
Project: activemq-artemis
File: TwoBrokerVirtualTopicForwardingTest.java
File: TwoBrokerVirtualTopicForwardingTest.java
public void testDontBridgeQueuesWithOnlyQueueConsumers() throws Exception { dontBridgeVirtualTopicConsumerQueues("BrokerA", "BrokerB"); startAllBrokers(); waitForBridgeFormation(); MessageConsumer clientA = createConsumer("BrokerA", createDestination("Consumer.A.VirtualTopic.tempTopic", false)); MessageConsumer clientB = createConsumer("BrokerB", createDestination("Consumer.B.VirtualTopic.tempTopic", false)); // give a sec to let advisories propagate Thread.sleep(500); ActiveMQQueue queueA = new ActiveMQQueue("Consumer.A.VirtualTopic.tempTopic"); Destination destination = getDestination(brokers.get("BrokerA").broker, queueA); assertEquals(1, destination.getConsumers().size()); ActiveMQQueue queueB = new ActiveMQQueue("Consumer.B.VirtualTopic.tempTopic"); destination = getDestination(brokers.get("BrokerA").broker, queueB); assertNull(destination); ActiveMQTopic virtualTopic = new ActiveMQTopic("VirtualTopic.tempTopic"); assertNull(getDestination(brokers.get("BrokerA").broker, virtualTopic)); assertNull(getDestination(brokers.get("BrokerB").broker, virtualTopic)); // send some messages sendMessages("BrokerA", virtualTopic, 1); MessageIdList msgsA = getConsumerMessages("BrokerA", clientA); MessageIdList msgsB = getConsumerMessages("BrokerB", clientB); msgsA.waitForMessagesToArrive(1); msgsB.waitForMessagesToArrive(0); // ensure we don't get any more messages Thread.sleep(2000); assertEquals(1, msgsA.getMessageCount()); assertEquals(0, msgsB.getMessageCount()); }
17. TwoBrokerVirtualTopicForwardingTest#testBridgeVirtualTopicQueues()
Project: activemq-artemis
File: TwoBrokerVirtualTopicForwardingTest.java
File: TwoBrokerVirtualTopicForwardingTest.java
public void testBridgeVirtualTopicQueues() throws Exception { bridgeAndConfigureBrokers("BrokerA", "BrokerB"); startAllBrokers(); waitForBridgeFormation(); MessageConsumer clientA = createConsumer("BrokerA", createDestination("Consumer.A.VirtualTopic.tempTopic", false)); MessageConsumer clientB = createConsumer("BrokerB", createDestination("Consumer.B.VirtualTopic.tempTopic", false)); // give a sec to let advisories propagate Thread.sleep(500); ActiveMQQueue queueA = new ActiveMQQueue("Consumer.A.VirtualTopic.tempTopic"); Destination destination = getDestination(brokers.get("BrokerA").broker, queueA); assertEquals(1, destination.getConsumers().size()); ActiveMQQueue queueB = new ActiveMQQueue("Consumer.B.VirtualTopic.tempTopic"); destination = getDestination(brokers.get("BrokerA").broker, queueB); assertEquals(1, destination.getConsumers().size()); ActiveMQTopic virtualTopic = new ActiveMQTopic("VirtualTopic.tempTopic"); assertNull(getDestination(brokers.get("BrokerA").broker, virtualTopic)); assertNull(getDestination(brokers.get("BrokerB").broker, virtualTopic)); // send some messages sendMessages("BrokerA", virtualTopic, 1); MessageIdList msgsA = getConsumerMessages("BrokerA", clientA); MessageIdList msgsB = getConsumerMessages("BrokerB", clientB); msgsA.waitForMessagesToArrive(1); msgsB.waitForMessagesToArrive(1); // ensure we don't get any more messages Thread.sleep(2000); assertEquals(1, msgsA.getMessageCount()); assertEquals(1, msgsB.getMessageCount()); }
18. DurableSubSelectorDelayWithRestartTest#setUp()
Project: activemq-artemis
File: DurableSubSelectorDelayWithRestartTest.java
File: DurableSubSelectorDelayWithRestartTest.java
@Before public void setUp() throws Exception { topic = new ActiveMQTopic("TopicT"); startBroker(); }
19. DurableSubSelectorDelayTest#setUp()
Project: activemq-artemis
File: DurableSubSelectorDelayTest.java
File: DurableSubSelectorDelayTest.java
@Before public void setUp() throws Exception { topic = new ActiveMQTopic("TopicT"); startBroker(); }
20. DurableSubscriptionOfflineTest#testRemovedDurableSubDeletes()
Project: activemq-artemis
File: DurableSubscriptionOfflineTest.java
File: DurableSubscriptionOfflineTest.java
@Test(timeout = 60 * 1000) public void testRemovedDurableSubDeletes() throws Exception { String filter = "$a='A1' AND (($b=true AND $c=true) OR ($d='D1' OR $d='D2'))"; // create durable subscription 1 Connection con = createConnection("cliId1"); Session session = con.createSession(false, Session.AUTO_ACKNOWLEDGE); session.createDurableSubscriber(topic, "SubsId", "filter = 'true'", true); session.close(); con.close(); // send messages con = createConnection(); session = con.createSession(false, Session.AUTO_ACKNOWLEDGE); MessageProducer producer = session.createProducer(null); for (int i = 0; i < 10; i++) { Message message = session.createMessage(); message.setStringProperty("filter", "true"); producer.send(topic, message); } Thread.sleep(1 * 1000); Connection con2 = createConnection("cliId1"); Session session2 = con2.createSession(false, Session.AUTO_ACKNOWLEDGE); session2.unsubscribe("SubsId"); session2.close(); con2.close(); // see if retroactive can consumer any topic = new ActiveMQTopic(topic.getPhysicalName() + "?consumer.retroactive=true"); con = createConnection("offCli2"); session = con.createSession(false, Session.AUTO_ACKNOWLEDGE); MessageConsumer consumer = session.createDurableSubscriber(topic, "SubsId", filter, true); DurableSubscriptionOfflineTestListener listener = new DurableSubscriptionOfflineTestListener(); consumer.setMessageListener(listener); session.close(); con.close(); assertEquals(0, listener.count); }
21. DurableSubscriberWithNetworkRestartTest#testSendOnAReceiveOnBWithTransportDisconnect()
Project: activemq-artemis
File: DurableSubscriberWithNetworkRestartTest.java
File: DurableSubscriberWithNetworkRestartTest.java
public void testSendOnAReceiveOnBWithTransportDisconnect() throws Exception { bridge(SPOKE, HUB); startAllBrokers(); verifyDuplexBridgeMbean(); // Setup connection URI hubURI = brokers.get(HUB).broker.getTransportConnectors().get(0).getPublishableConnectURI(); URI spokeURI = brokers.get(SPOKE).broker.getTransportConnectors().get(0).getPublishableConnectURI(); ActiveMQConnectionFactory facHub = new ActiveMQConnectionFactory(hubURI); ActiveMQConnectionFactory facSpoke = new ActiveMQConnectionFactory(spokeURI); Connection conHub = facHub.createConnection(); Connection conSpoke = facSpoke.createConnection(); conHub.setClientID("clientHUB"); conSpoke.setClientID("clientSPOKE"); conHub.start(); conSpoke.start(); Session sesHub = conHub.createSession(false, Session.AUTO_ACKNOWLEDGE); Session sesSpoke = conSpoke.createSession(false, Session.AUTO_ACKNOWLEDGE); ActiveMQTopic topic = new ActiveMQTopic("TEST.FOO"); String consumerName = "consumerName"; // Setup consumers MessageConsumer remoteConsumer = sesHub.createDurableSubscriber(topic, consumerName); sleep(1000); remoteConsumer.close(); // Setup producer MessageProducer localProducer = sesSpoke.createProducer(topic); localProducer.setDeliveryMode(DeliveryMode.PERSISTENT); final String payloadString = new String(new byte[10 * 1024]); // Send messages for (int i = 0; i < MESSAGE_COUNT; i++) { Message test = sesSpoke.createTextMessage("test-" + i); test.setStringProperty("payload", payloadString); localProducer.send(test); } localProducer.close(); final String options = "?persistent=true&useJmx=true&deleteAllMessagesOnStartup=false"; for (int i = 0; i < 2; i++) { brokers.get(SPOKE).broker.stop(); sleep(1000); createBroker(new URI("broker:(tcp://localhost:61616)/" + SPOKE + options)); bridge(SPOKE, HUB); brokers.get(SPOKE).broker.start(); LOG.info("restarted spoke..:" + i); assertTrue("got mbeans on restart", Wait.waitFor(new Wait.Condition() { @Override public boolean isSatisified() throws Exception { return countMbeans(brokers.get(HUB).broker, "networkBridge", 20000) == (dynamicOnly ? 1 : 2); } })); } }
22. DurableSubscriberWithNetworkDisconnectTest#testSendOnAReceiveOnBWithTransportDisconnect()
Project: activemq-artemis
File: DurableSubscriberWithNetworkDisconnectTest.java
File: DurableSubscriberWithNetworkDisconnectTest.java
public void testSendOnAReceiveOnBWithTransportDisconnect() throws Exception { bridgeBrokers(SPOKE, HUB); startAllBrokers(); // Setup connection URI hubURI = brokers.get(HUB).broker.getVmConnectorURI(); URI spokeURI = brokers.get(SPOKE).broker.getVmConnectorURI(); ActiveMQConnectionFactory facHub = new ActiveMQConnectionFactory(hubURI); ActiveMQConnectionFactory facSpoke = new ActiveMQConnectionFactory(spokeURI); Connection conHub = facHub.createConnection(); Connection conSpoke = facSpoke.createConnection(); conHub.setClientID("clientHUB"); conSpoke.setClientID("clientSPOKE"); conHub.start(); conSpoke.start(); Session sesHub = conHub.createSession(false, Session.AUTO_ACKNOWLEDGE); Session sesSpoke = conSpoke.createSession(false, Session.AUTO_ACKNOWLEDGE); ActiveMQTopic topic = new ActiveMQTopic("TEST.FOO"); String consumerName = "consumerName"; // Setup consumers MessageConsumer remoteConsumer = sesSpoke.createDurableSubscriber(topic, consumerName); remoteConsumer.setMessageListener(new MessageListener() { @Override public void onMessage(Message msg) { try { TextMessage textMsg = (TextMessage) msg; receivedMsgs++; LOG.info("Received messages (" + receivedMsgs + "): " + textMsg.getText()); } catch (JMSException e) { e.printStackTrace(); } } }); // allow subscription information to flow back to Spoke sleep(1000); // Setup producer MessageProducer localProducer = sesHub.createProducer(topic); localProducer.setDeliveryMode(DeliveryMode.PERSISTENT); // Send messages for (int i = 0; i < MESSAGE_COUNT; i++) { sleep(50); if (i == 50 || i == 150) { if (simulateStalledNetwork) { socketProxy.pause(); } else { socketProxy.close(); } networkDownTimeStart = System.currentTimeMillis(); } else if (networkDownTimeStart > 0) { // restart after NETWORK_DOWN_TIME seconds sleep(NETWORK_DOWN_TIME); networkDownTimeStart = 0; if (simulateStalledNetwork) { socketProxy.goOn(); } else { socketProxy.reopen(); } } else { // slow message production to allow bridge to recover and limit message duplication sleep(500); } Message test = sesHub.createTextMessage("test-" + i); localProducer.send(test); } LOG.info("waiting for messages to flow"); Wait.waitFor(new Wait.Condition() { @Override public boolean isSatisified() throws Exception { return receivedMsgs >= MESSAGE_COUNT; } }); assertTrue("At least message " + MESSAGE_COUNT + " must be received, count=" + receivedMsgs, MESSAGE_COUNT <= receivedMsgs); brokers.get(HUB).broker.deleteAllMessages(); brokers.get(SPOKE).broker.deleteAllMessages(); conHub.close(); conSpoke.close(); }
23. DurableSubProcessWithRestartTest#setUp()
Project: activemq-artemis
File: DurableSubProcessWithRestartTest.java
File: DurableSubProcessWithRestartTest.java
@Before public void setUp() throws Exception { topic = new ActiveMQTopic("TopicT"); startBroker(); clientManager = new ClientManager(); server = new Server(); houseKeeper = new HouseKeeper(); }
24. DurableSubProcessMultiRestartTest#setUp()
Project: activemq-artemis
File: DurableSubProcessMultiRestartTest.java
File: DurableSubProcessMultiRestartTest.java
@Before public void setUp() throws Exception { topic = new ActiveMQTopic("TopicT"); startBroker(); }
25. DurableSubProcessConcurrentCommitActivateNoDuplicateTest#setUp()
Project: activemq-artemis
File: DurableSubProcessConcurrentCommitActivateNoDuplicateTest.java
File: DurableSubProcessConcurrentCommitActivateNoDuplicateTest.java
@Before public void setUp() throws Exception { topic = new ActiveMQTopic("TopicT"); startBroker(); clientManager = new ClientManager(); server = new Server(); houseKeeper = new HouseKeeper(); }
26. DurableSubDelayedUnsubscribeTest#setUp()
Project: activemq-artemis
File: DurableSubDelayedUnsubscribeTest.java
File: DurableSubDelayedUnsubscribeTest.java
@Before public void setUp() throws Exception { topic = new ActiveMQTopic("TopicT"); startBroker(); clientManager = new ClientManager(); server = new Server(); houseKeeper = new HouseKeeper(); }
27. RetroactiveConsumerTestWithLastImagePolicyWithWildcardTest#sendMessage()
Project: activemq-artemis
File: RetroactiveConsumerTestWithLastImagePolicyWithWildcardTest.java
File: RetroactiveConsumerTestWithLastImagePolicyWithWildcardTest.java
@Override protected void sendMessage(MessageProducer producer, TextMessage message) throws JMSException { ActiveMQTopic topic = new ActiveMQTopic(destination.getPhysicalName() + "." + (counter++)); producer.send(topic, message); }
28. RemoveDestinationTest#testRemoveDestinationWithSubscriber()
Project: activemq-artemis
File: RemoveDestinationTest.java
File: RemoveDestinationTest.java
@Test public void testRemoveDestinationWithSubscriber() throws Exception { ActiveMQConnection amqConnection = (ActiveMQConnection) createConnection(true); DestinationSource destinationSource = amqConnection.getDestinationSource(); Session session = amqConnection.createSession(false, Session.AUTO_ACKNOWLEDGE); Topic topic = session.createTopic("TEST.FOO"); MessageProducer producer = session.createProducer(topic); MessageConsumer consumer = session.createConsumer(topic); TextMessage msg = session.createTextMessage("Hellow World"); producer.send(msg); assertNotNull(consumer.receive(5000)); Thread.sleep(1000); ActiveMQTopic amqTopic = (ActiveMQTopic) topic; assertTrue(destinationPresentInAdminView(amqTopic)); assertTrue(destinationSource.getTopics().contains(amqTopic)); // This line generates a broker error since the consumer is still active. try { amqConnection.destroyDestination((ActiveMQDestination) topic); fail("expect exception on destroy if comsumer present"); } catch (JMSException expected) { assertTrue(expected.getMessage().indexOf(amqTopic.getTopicName()) != -1); } Thread.sleep(3000); assertTrue(destinationSource.getTopics().contains(amqTopic)); assertTrue(destinationPresentInAdminView(amqTopic)); consumer.close(); producer.close(); session.close(); Thread.sleep(3000); // The destination will not be removed with this call, but if you remove // the call above that generates the error it will. amqConnection.destroyDestination(amqTopic); Thread.sleep(3000); assertFalse(destinationSource.getTopics().contains(amqTopic)); assertFalse(destinationPresentInAdminView(amqTopic)); }
29. RemoveDestinationTest#testRemoveDestinationWithoutSubscriber()
Project: activemq-artemis
File: RemoveDestinationTest.java
File: RemoveDestinationTest.java
@Test public void testRemoveDestinationWithoutSubscriber() throws Exception { ActiveMQConnection amqConnection = (ActiveMQConnection) createConnection(true); DestinationSource destinationSource = amqConnection.getDestinationSource(); Session session = amqConnection.createSession(false, Session.AUTO_ACKNOWLEDGE); Topic topic = session.createTopic("TEST.FOO"); MessageProducer producer = session.createProducer(topic); MessageConsumer consumer = session.createConsumer(topic); TextMessage msg = session.createTextMessage("Hellow World"); producer.send(msg); assertNotNull(consumer.receive(5000)); Thread.sleep(1000); ActiveMQTopic amqTopic = (ActiveMQTopic) topic; assertTrue(destinationSource.getTopics().contains(amqTopic)); consumer.close(); producer.close(); session.close(); Thread.sleep(3000); amqConnection.destroyDestination((ActiveMQDestination) topic); Thread.sleep(3000); assertFalse(destinationSource.getTopics().contains(amqTopic)); }
30. RedeliveryPolicyTest#testRedeliveryPolicyPerDestination()
Project: activemq-artemis
File: RedeliveryPolicyTest.java
File: RedeliveryPolicyTest.java
public void testRedeliveryPolicyPerDestination() throws Exception { RedeliveryPolicy queuePolicy = new RedeliveryPolicy(); queuePolicy.setInitialRedeliveryDelay(0); queuePolicy.setRedeliveryDelay(1000); queuePolicy.setUseExponentialBackOff(false); queuePolicy.setMaximumRedeliveries(2); RedeliveryPolicy topicPolicy = new RedeliveryPolicy(); topicPolicy.setInitialRedeliveryDelay(0); topicPolicy.setRedeliveryDelay(1000); topicPolicy.setUseExponentialBackOff(false); topicPolicy.setMaximumRedeliveries(3); // Receive a message with the JMS API RedeliveryPolicyMap map = connection.getRedeliveryPolicyMap(); map.put(new ActiveMQTopic(">"), topicPolicy); map.put(new ActiveMQQueue(">"), queuePolicy); connection.start(); Session session = connection.createSession(true, Session.AUTO_ACKNOWLEDGE); ActiveMQQueue queue = new ActiveMQQueue("TEST"); ActiveMQTopic topic = new ActiveMQTopic("TEST"); MessageProducer producer = session.createProducer(null); MessageConsumer queueConsumer = session.createConsumer(queue); MessageConsumer topicConsumer = session.createConsumer(topic); // Send the messages producer.send(queue, session.createTextMessage("1st")); producer.send(queue, session.createTextMessage("2nd")); producer.send(topic, session.createTextMessage("1st")); producer.send(topic, session.createTextMessage("2nd")); session.commit(); TextMessage m; m = (TextMessage) queueConsumer.receive(100); assertNotNull(m); assertEquals("1st", m.getText()); m = (TextMessage) topicConsumer.receive(100); assertNotNull(m); assertEquals("1st", m.getText()); m = (TextMessage) queueConsumer.receive(100); assertNotNull(m); assertEquals("2nd", m.getText()); m = (TextMessage) topicConsumer.receive(100); assertNotNull(m); assertEquals("2nd", m.getText()); session.rollback(); m = (TextMessage) queueConsumer.receive(100); assertNotNull("first immediate redelivery", m); m = (TextMessage) topicConsumer.receive(100); assertNotNull("first immediate redelivery", m); session.rollback(); m = (TextMessage) queueConsumer.receive(100); assertNull("second delivery delayed: " + m, m); m = (TextMessage) topicConsumer.receive(100); assertNull("second delivery delayed: " + m, m); m = (TextMessage) queueConsumer.receive(2000); assertNotNull(m); assertEquals("1st", m.getText()); m = (TextMessage) topicConsumer.receive(2000); assertNotNull(m); assertEquals("1st", m.getText()); m = (TextMessage) queueConsumer.receive(100); assertNotNull(m); assertEquals("2nd", m.getText()); m = (TextMessage) topicConsumer.receive(100); assertNotNull(m); assertEquals("2nd", m.getText()); session.rollback(); m = (TextMessage) queueConsumer.receive(2000); assertNotNull(m); assertEquals("1st", m.getText()); m = (TextMessage) topicConsumer.receive(2000); assertNotNull(m); assertEquals("1st", m.getText()); m = (TextMessage) queueConsumer.receive(100); assertNotNull(m); assertEquals("2nd", m.getText()); m = (TextMessage) topicConsumer.receive(100); assertNotNull(m); assertEquals("2nd", m.getText()); session.rollback(); // No third attempt for the Queue consumer m = (TextMessage) queueConsumer.receive(2000); assertNull(m); m = (TextMessage) topicConsumer.receive(2000); assertNotNull(m); assertEquals("1st", m.getText()); m = (TextMessage) queueConsumer.receive(100); assertNull(m); m = (TextMessage) topicConsumer.receive(100); assertNotNull(m); assertEquals("2nd", m.getText()); session.commit(); }
31. ActiveMQTopicTest#populateObject()
Project: activemq-artemis
File: ActiveMQTopicTest.java
File: ActiveMQTopicTest.java
@Override protected void populateObject(Object object) throws Exception { super.populateObject(object); ActiveMQTopic info = (ActiveMQTopic) object; }
32. ActiveMQTopicTest#createObject()
Project: activemq-artemis
File: ActiveMQTopicTest.java
File: ActiveMQTopicTest.java
@Override public Object createObject() throws Exception { ActiveMQTopic info = new ActiveMQTopic(); populateObject(info); return info; }
33. ActiveMQTopicTest#populateObject()
Project: activemq-artemis
File: ActiveMQTopicTest.java
File: ActiveMQTopicTest.java
@Override protected void populateObject(Object object) throws Exception { super.populateObject(object); ActiveMQTopic info = (ActiveMQTopic) object; }
34. ActiveMQTopicTest#createObject()
Project: activemq-artemis
File: ActiveMQTopicTest.java
File: ActiveMQTopicTest.java
@Override public Object createObject() throws Exception { ActiveMQTopic info = new ActiveMQTopic(); populateObject(info); return info; }
35. NetworkBrokerDetachTest#testNetworkedBrokerDurableSubAfterRestart()
Project: activemq-artemis
File: NetworkBrokerDetachTest.java
File: NetworkBrokerDetachTest.java
@Test public void testNetworkedBrokerDurableSubAfterRestart() throws Exception { final AtomicInteger count = new AtomicInteger(0); MessageListener counter = new MessageListener() { @Override public void onMessage(Message message) { count.incrementAndGet(); } }; LOG.info("Creating durable consumer on each broker ..."); ActiveMQTopic destination = registerDurableConsumer(networkedBroker, counter); registerDurableConsumer(broker, counter); assertTrue("got expected consumer count from local broker mbean within time limit", verifyConsumerCount(2, destination, broker)); assertTrue("got expected consumer count from network broker mbean within time limit", verifyConsumerCount(2, destination, networkedBroker)); sendMessageTo(destination, broker); assertTrue("Got one message on each", verifyMessageCount(2, count)); LOG.info("Stopping brokerTwo..."); networkedBroker.stop(); networkedBroker.waitUntilStopped(); LOG.info("restarting broker Two..."); networkedBroker = createNetworkedBroker(); networkedBroker.start(); LOG.info("Recreating durable Consumer on the broker after restart..."); registerDurableConsumer(networkedBroker, counter); // give advisories a chance to percolate TimeUnit.SECONDS.sleep(5); sendMessageTo(destination, broker); // expect similar after restart assertTrue("got expected consumer count from local broker mbean within time limit", verifyConsumerCount(2, destination, broker)); // a durable sub is auto bridged on restart unless dynamicOnly=true assertTrue("got expected consumer count from network broker mbean within time limit", verifyConsumerCount(2, destination, networkedBroker)); assertTrue("got no inactive subs on broker", verifyDurableConsumerCount(0, broker)); assertTrue("got no inactive subs on other broker", verifyDurableConsumerCount(0, networkedBroker)); assertTrue("Got two more messages after restart", verifyMessageCount(4, count)); TimeUnit.SECONDS.sleep(1); assertTrue("still Got just two more messages", verifyMessageCount(4, count)); }
36. TopicOutboundBridgeReconnectTest#setUp()
Project: activemq-artemis
File: TopicOutboundBridgeReconnectTest.java
File: TopicOutboundBridgeReconnectTest.java
@Before public void setUp() throws Exception { producerConnectionFactory = createProducerConnectionFactory(); consumerConnectionFactory = createConsumerConnectionFactory(); destination = new ActiveMQTopic("RECONNECT.TEST.TOPIC"); }
37. JmsSessionRecoverTest#testTopicAsynchRecoverWithAutoAck()
Project: activemq-artemis
File: JmsSessionRecoverTest.java
File: JmsSessionRecoverTest.java
/** * @throws JMSException * @throws InterruptedException */ public void testTopicAsynchRecoverWithAutoAck() throws JMSException, InterruptedException { dest = new ActiveMQTopic("Topic-" + System.currentTimeMillis()); doTestAsynchRecoverWithAutoAck(); }
38. JmsSessionRecoverTest#testTopicAsynchRecover()
Project: activemq-artemis
File: JmsSessionRecoverTest.java
File: JmsSessionRecoverTest.java
/** * @throws JMSException * @throws InterruptedException */ public void testTopicAsynchRecover() throws JMSException, InterruptedException { dest = new ActiveMQTopic("Topic-" + System.currentTimeMillis()); doTestAsynchRecover(); }
39. JmsSessionRecoverTest#testTopicSynchRecover()
Project: activemq-artemis
File: JmsSessionRecoverTest.java
File: JmsSessionRecoverTest.java
/** * @throws JMSException * @throws InterruptedException */ public void testTopicSynchRecover() throws JMSException, InterruptedException { dest = new ActiveMQTopic("Topic-" + System.currentTimeMillis()); doTestSynchRecover(); }
40. DestinationMapTest#testQueueAndTopicWithSameName()
Project: activemq-artemis
File: DestinationMapTest.java
File: DestinationMapTest.java
public void testQueueAndTopicWithSameName() throws Exception { ActiveMQQueue q1 = new ActiveMQQueue("foo"); ActiveMQTopic t1 = new ActiveMQTopic("foo"); map.put(q1, v1); map.put(t1, v2); assertMapValue(q1, v1); assertMapValue(t1, v2); }
41. DestinationMapMemoryTest#testLongDestinationPath()
Project: activemq-artemis
File: DestinationMapMemoryTest.java
File: DestinationMapMemoryTest.java
public void testLongDestinationPath() throws Exception { ActiveMQTopic d1 = new ActiveMQTopic("1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18"); DestinationMap map = new DestinationMap(); map.put(d1, d1); }
42. RedeliveryRestartTest#testDurableSubRedeliveryFlagAfterRestartNotSupported()
Project: activemq-artemis
File: RedeliveryRestartTest.java
File: RedeliveryRestartTest.java
@org.junit.Test public void testDurableSubRedeliveryFlagAfterRestartNotSupported() throws Exception { ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("failover:(" + broker.getTransportConnectors().get(0).getPublishableConnectString() + ")?jms.prefetchPolicy.all=0"); connection = (ActiveMQConnection) connectionFactory.createConnection(); connection.setClientID("id"); connection.start(); Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE); ActiveMQTopic destination = new ActiveMQTopic(queueName); TopicSubscriber durableSub = session.createDurableSubscriber(destination, "id"); populateDestination(10, destination, connection); TextMessage msg = null; for (int i = 0; i < 5; i++) { msg = (TextMessage) durableSub.receive(20000); LOG.info("not redelivered? got: " + msg); assertNotNull("got the message", msg); assertEquals("first delivery", 1, msg.getLongProperty("JMSXDeliveryCount")); assertEquals("not a redelivery", false, msg.getJMSRedelivered()); } durableSub.close(); restartBroker(); // make failover aware of the restarted auto assigned port connection.getTransport().narrow(FailoverTransport.class).add(true, broker.getTransportConnectors().get(0).getPublishableConnectString()); durableSub = session.createDurableSubscriber(destination, "id"); for (int i = 0; i < 10; i++) { msg = (TextMessage) durableSub.receive(4000); LOG.info("redelivered? got: " + msg); assertNotNull("got the message again", msg); assertEquals("no reDelivery flag", false, msg.getJMSRedelivered()); msg.acknowledge(); } connection.close(); }