Search in sources :

Example 6 with MessageIdList

use of org.apache.activemq.util.MessageIdList in project activemq-artemis by apache.

the class ThreeBrokerQueueNetworkTest method XtestMigrateConsumerStuckMessages.

/*
    * This test is disabled - as it fails with a fix for
    * http://issues.apache.org/activemq/browse/AMQ-2530 - which highlights that
    * For a Conduit bridge - local subscription Ids weren't removed in a ConduitBridge
    * The test fails because on closing clientA - clientB correctly receives all the
    * messages - ie. half dont get stuck on BrokerA -
    */
public void XtestMigrateConsumerStuckMessages() throws Exception {
    boolean suppressQueueDuplicateSubscriptions = false;
    bridgeAllBrokers("default", 3, suppressQueueDuplicateSubscriptions);
    startAllBrokers();
    waitForBridgeFormation();
    // Setup destination
    Destination dest = createDestination("TEST.FOO", false);
    // Setup consumers
    LOG.info("Consumer on A");
    MessageConsumer clientA = createConsumer("BrokerA", dest);
    // ensure advisors have percolated
    Thread.sleep(2000);
    LOG.info("Consumer on B");
    int messageCount = 2000;
    // will only get half of the messages
    CountDownLatch messagesReceived = new CountDownLatch(messageCount / 2);
    MessageConsumer clientB = createConsumer("BrokerB", dest, messagesReceived);
    // ensure advisors have percolated
    Thread.sleep(2000);
    LOG.info("Close consumer on A");
    clientA.close();
    // ensure advisors have percolated
    Thread.sleep(2000);
    LOG.info("Send to B");
    sendMessages("BrokerB", dest, messageCount);
    // Let's try to wait for any messages.
    assertTrue(messagesReceived.await(30, TimeUnit.SECONDS));
    // Get message count
    MessageIdList msgs = getConsumerMessages("BrokerB", clientB);
    // see will any more arrive
    Thread.sleep(500);
    assertEquals(messageCount / 2, msgs.getMessageCount());
    // pick up the stuck messages
    messagesReceived = new CountDownLatch(messageCount / 2);
    clientA = createConsumer("BrokerA", dest, messagesReceived);
    // Let's try to wait for any messages.
    assertTrue(messagesReceived.await(30, TimeUnit.SECONDS));
    msgs = getConsumerMessages("BrokerA", clientA);
    assertEquals(messageCount / 2, msgs.getMessageCount());
}
Also used : ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination) Destination(javax.jms.Destination) MessageConsumer(javax.jms.MessageConsumer) CountDownLatch(java.util.concurrent.CountDownLatch) MessageIdList(org.apache.activemq.util.MessageIdList)

Example 7 with MessageIdList

use of org.apache.activemq.util.MessageIdList in project activemq-artemis by apache.

the class ThreeBrokerQueueNetworkTest method testAllConnectedUsingMulticast.

public void testAllConnectedUsingMulticast() throws Exception {
    // Setup broker networks
    bridgeAllBrokers();
    startAllBrokers();
    waitForBridgeFormation();
    // Setup destination
    Destination dest = createDestination("TEST.FOO", false);
    // Setup consumers
    MessageConsumer clientA = createConsumer("BrokerA", dest);
    MessageConsumer clientB = createConsumer("BrokerB", dest);
    MessageConsumer clientC = createConsumer("BrokerC", dest);
    // Send messages
    sendMessages("BrokerA", dest, MESSAGE_COUNT);
    sendMessages("BrokerB", dest, MESSAGE_COUNT);
    sendMessages("BrokerC", dest, MESSAGE_COUNT);
    // Let's try to wait for any messages.
    Thread.sleep(1000);
    // Get message count
    final MessageIdList msgsA = getConsumerMessages("BrokerA", clientA);
    MessageIdList msgsB = getConsumerMessages("BrokerB", clientB);
    MessageIdList msgsC = getConsumerMessages("BrokerC", clientC);
    waitFor(new Condition() {

        @Override
        public boolean isSatisified() {
            return msgsA.getMessageCount() == MESSAGE_COUNT;
        }
    });
    assertEquals(MESSAGE_COUNT * 3, msgsA.getMessageCount() + msgsB.getMessageCount() + msgsC.getMessageCount());
}
Also used : ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination) Destination(javax.jms.Destination) MessageConsumer(javax.jms.MessageConsumer) MessageIdList(org.apache.activemq.util.MessageIdList)

Example 8 with MessageIdList

use of org.apache.activemq.util.MessageIdList in project activemq-artemis by apache.

the class TwoBrokerVirtualTopicForwardingTest method testDontBridgeQueuesWithBothTypesConsumers.

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());
}
Also used : TestSupport.getDestination(org.apache.activemq.TestSupport.getDestination) ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination) Destination(org.apache.activemq.broker.region.Destination) MessageConsumer(javax.jms.MessageConsumer) ActiveMQTopic(org.apache.activemq.command.ActiveMQTopic) ActiveMQQueue(org.apache.activemq.command.ActiveMQQueue) MessageIdList(org.apache.activemq.util.MessageIdList)

Example 9 with MessageIdList

use of org.apache.activemq.util.MessageIdList in project activemq-artemis by apache.

the class TwoBrokerVirtualTopicForwardingTest method testBridgeVirtualTopicQueues.

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());
}
Also used : TestSupport.getDestination(org.apache.activemq.TestSupport.getDestination) ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination) Destination(org.apache.activemq.broker.region.Destination) MessageConsumer(javax.jms.MessageConsumer) ActiveMQTopic(org.apache.activemq.command.ActiveMQTopic) ActiveMQQueue(org.apache.activemq.command.ActiveMQQueue) MessageIdList(org.apache.activemq.util.MessageIdList)

Example 10 with MessageIdList

use of org.apache.activemq.util.MessageIdList in project activemq-artemis by apache.

the class TwoBrokerVirtualTopicForwardingTest method testDontBridgeQueuesWithOnlyQueueConsumers.

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());
}
Also used : TestSupport.getDestination(org.apache.activemq.TestSupport.getDestination) ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination) Destination(org.apache.activemq.broker.region.Destination) MessageConsumer(javax.jms.MessageConsumer) ActiveMQTopic(org.apache.activemq.command.ActiveMQTopic) ActiveMQQueue(org.apache.activemq.command.ActiveMQQueue) MessageIdList(org.apache.activemq.util.MessageIdList)

Aggregations

MessageIdList (org.apache.activemq.util.MessageIdList)63 MessageConsumer (javax.jms.MessageConsumer)58 Destination (javax.jms.Destination)34 ActiveMQDestination (org.apache.activemq.command.ActiveMQDestination)31 CountDownLatch (java.util.concurrent.CountDownLatch)8 Connection (javax.jms.Connection)6 VirtualDestination (org.apache.activemq.broker.region.virtual.VirtualDestination)5 Test (org.junit.Test)5 URI (java.net.URI)4 BrokerService (org.apache.activemq.broker.BrokerService)4 ActiveMQQueue (org.apache.activemq.command.ActiveMQQueue)4 NetworkConnector (org.apache.activemq.network.NetworkConnector)4 HashMap (java.util.HashMap)3 Session (javax.jms.Session)3 ActiveMQMessageConsumer (org.apache.activemq.ActiveMQMessageConsumer)3 TestSupport.getDestination (org.apache.activemq.TestSupport.getDestination)3 Destination (org.apache.activemq.broker.region.Destination)3 PolicyEntry (org.apache.activemq.broker.region.policy.PolicyEntry)3 PolicyMap (org.apache.activemq.broker.region.policy.PolicyMap)3 ActiveMQTopic (org.apache.activemq.command.ActiveMQTopic)3