Search in sources :

Example 56 with MessageIdList

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

the class TwoBrokerVirtualDestDinamicallyIncludedDestTest method testVirtualDestinationsDinamicallyIncludedBehavior3.

/**
 * BrokerA -> BrokerB && BrokerB -> BrokerA
 */
public void testVirtualDestinationsDinamicallyIncludedBehavior3() throws Exception {
    final String topic = "global.test";
    final String vq = "Consumer.foo." + topic;
    startAllBrokers();
    final int msgs1 = 1001;
    final int msgs2 = 1456;
    // Setup destination
    Destination tDest = createDestination(topic, true);
    Destination vqDest = createDestination(vq, false);
    // Setup consumers
    MessageConsumer clientB1t = createConsumer("BrokerA", tDest);
    MessageConsumer clientB2t = createConsumer("BrokerB", tDest);
    MessageConsumer clientB1vq = createConsumer("BrokerA", vqDest);
    Thread.sleep(2 * 1000);
    // Send messages
    sendMessages("BrokerA", tDest, msgs1);
    sendMessages("BrokerB", tDest, msgs2);
    Thread.sleep(5000);
    // Get message count
    MessageIdList msgsB1t = getConsumerMessages("BrokerA", clientB1t);
    msgsB1t.waitForMessagesToArrive(msgs1 + msgs2);
    assertEquals(msgs1 + msgs2, msgsB1t.getMessageCount());
    MessageIdList msgsB2t = getConsumerMessages("BrokerB", clientB2t);
    msgsB2t.waitForMessagesToArrive(msgs1 + msgs2);
    assertEquals(msgs1 + msgs2, msgsB2t.getMessageCount());
    MessageIdList msgsB1vq = getConsumerMessages("BrokerA", clientB1vq);
    msgsB1vq.waitForMessagesToArrive(msgs1 + msgs2);
    assertEquals(msgs1 + msgs2, msgsB1vq.getMessageCount());
    assertEquals(0, getQueueSize("BrokerA", (ActiveMQDestination) vqDest));
    assertEquals(0, getQueueSize("BrokerB", (ActiveMQDestination) vqDest));
    destroyAllBrokers();
}
Also used : VirtualDestination(org.apache.activemq.broker.region.virtual.VirtualDestination) ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination) Destination(javax.jms.Destination) MessageConsumer(javax.jms.MessageConsumer) MessageIdList(org.apache.activemq.util.MessageIdList) ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination)

Example 57 with MessageIdList

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

the class MultiBrokersMultiClientsTest method testTopicAllConnected.

public void testTopicAllConnected() throws Exception {
    bridgeAllBrokers();
    startAllBrokers();
    waitForBridgeFormation();
    // Setup topic destination
    Destination dest = createDestination("TEST.FOO", true);
    CountDownLatch latch = new CountDownLatch(BROKER_COUNT * PRODUCER_COUNT * BROKER_COUNT * CONSUMER_COUNT * MESSAGE_COUNT);
    // Setup consumers
    for (int i = 1; i <= BROKER_COUNT; i++) {
        for (int j = 0; j < CONSUMER_COUNT; j++) {
            consumerMap.put("Consumer:" + i + ":" + j, createConsumer("Broker" + i, dest, latch));
        }
    }
    // wait for consumers to get propagated
    for (int i = 1; i <= BROKER_COUNT; i++) {
        // all consumers on the remote brokers look like 1 consumer to the local broker.
        assertConsumersConnect("Broker" + i, dest, (BROKER_COUNT - 1) + CONSUMER_COUNT, 65000);
    }
    // Send messages
    for (int i = 1; i <= BROKER_COUNT; i++) {
        for (int j = 0; j < PRODUCER_COUNT; j++) {
            sendMessages("Broker" + i, dest, MESSAGE_COUNT);
        }
    }
    assertTrue("Missing " + latch.getCount() + " messages", latch.await(45, TimeUnit.SECONDS));
    // Get message count
    for (int i = 1; i <= BROKER_COUNT; i++) {
        for (int j = 0; j < CONSUMER_COUNT; j++) {
            MessageIdList msgs = getConsumerMessages("Broker" + i, consumerMap.get("Consumer:" + i + ":" + j));
            assertEquals(BROKER_COUNT * PRODUCER_COUNT * MESSAGE_COUNT, msgs.getMessageCount());
        }
    }
    assertNoUnhandeledExceptions();
}
Also used : Destination(javax.jms.Destination) CountDownLatch(java.util.concurrent.CountDownLatch) MessageIdList(org.apache.activemq.util.MessageIdList)

Example 58 with MessageIdList

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

the class AMQ2927Test method testSendRestart.

public void testSendRestart() throws Exception {
    Thread.sleep(1000);
    LOG.info("sending message");
    sendMessages("BrokerA", queue, 1);
    Thread.sleep(3000);
    LOG.info("restarting broker");
    restartBroker("BrokerA");
    Thread.sleep(5000);
    LOG.info("consuming message");
    MessageConsumer consumerA = createConsumer("BrokerA", queue);
    MessageConsumer consumerB = createConsumer("BrokerB", queue);
    Thread.sleep(1000);
    MessageIdList messagesA = getConsumerMessages("BrokerA", consumerA);
    MessageIdList messagesB = getConsumerMessages("BrokerB", consumerB);
    LOG.info("consumerA = " + messagesA);
    LOG.info("consumerB = " + messagesB);
    messagesA.assertMessagesReceived(0);
    messagesB.assertMessagesReceived(1);
}
Also used : MessageConsumer(javax.jms.MessageConsumer) MessageIdList(org.apache.activemq.util.MessageIdList)

Example 59 with MessageIdList

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

the class AMQ2927Test method testRestartSend.

public void testRestartSend() throws Exception {
    Thread.sleep(1000);
    LOG.info("restarting broker");
    restartBroker("BrokerA");
    Thread.sleep(5000);
    LOG.info("sending message");
    sendMessages("BrokerA", queue, 1);
    Thread.sleep(3000);
    LOG.info("consuming message");
    MessageConsumer consumerA = createConsumer("BrokerA", queue);
    MessageConsumer consumerB = createConsumer("BrokerB", queue);
    Thread.sleep(1000);
    MessageIdList messagesA = getConsumerMessages("BrokerA", consumerA);
    MessageIdList messagesB = getConsumerMessages("BrokerB", consumerB);
    LOG.info("consumerA = " + messagesA);
    LOG.info("consumerB = " + messagesB);
    messagesA.assertMessagesReceived(0);
    messagesB.assertMessagesReceived(1);
}
Also used : MessageConsumer(javax.jms.MessageConsumer) MessageIdList(org.apache.activemq.util.MessageIdList)

Example 60 with MessageIdList

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

the class BrokerQueueNetworkWithDisconnectTest method testSendOnAReceiveOnBWithTransportDisconnect.

public void testSendOnAReceiveOnBWithTransportDisconnect() throws Exception {
    bridgeBrokers(SPOKE, HUB);
    startAllBrokers();
    // Setup destination
    Destination dest = createDestination("TEST.FOO", false);
    // Setup consumers
    MessageConsumer client = createConsumer(HUB, dest);
    // allow subscription information to flow back to Spoke
    sleep(600);
    // Send messages
    sendMessages(SPOKE, dest, MESSAGE_COUNT);
    MessageIdList msgs = getConsumerMessages(HUB, client);
    msgs.waitForMessagesToArrive(MESSAGE_COUNT);
    assertTrue("At least message " + MESSAGE_COUNT + " must be received, duplicates are expected, count=" + msgs.getMessageCount(), MESSAGE_COUNT <= msgs.getMessageCount());
}
Also used : Destination(javax.jms.Destination) MessageConsumer(javax.jms.MessageConsumer) 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