Search in sources :

Example 1 with MessageIdList

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

the class JmsMultipleClientsTestSupport method assertConsumerReceivedAtLeastXMessages.

/*
    * Some helpful assertions for multiple consumers.
    */
protected void assertConsumerReceivedAtLeastXMessages(MessageConsumer consumer, int msgCount) {
    MessageIdList messageIdList = consumers.get(consumer);
    messageIdList.assertAtLeastMessagesReceived(msgCount);
}
Also used : MessageIdList(org.apache.activemq.util.MessageIdList)

Example 2 with MessageIdList

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

the class ThreeBrokerTopicNetworkTest method testABandCBbrokerNetwork.

/**
 * BrokerA -> BrokerB <- BrokerC
 */
public void testABandCBbrokerNetwork() throws Exception {
    // Setup broker networks
    bridgeBrokers("BrokerA", "BrokerB");
    bridgeBrokers("BrokerC", "BrokerB");
    startAllBrokers();
    // Setup destination
    Destination dest = createDestination("TEST.FOO", true);
    // Setup consumers
    MessageConsumer clientA = createConsumer("BrokerA", dest);
    MessageConsumer clientB = createConsumer("BrokerB", dest);
    MessageConsumer clientC = createConsumer("BrokerC", dest);
    // let consumers propagate around the network
    Thread.sleep(2000);
    // Send messages
    sendMessages("BrokerA", dest, MESSAGE_COUNT);
    sendMessages("BrokerB", dest, MESSAGE_COUNT);
    sendMessages("BrokerC", dest, MESSAGE_COUNT);
    // Get message count
    MessageIdList msgsA = getConsumerMessages("BrokerA", clientA);
    MessageIdList msgsB = getConsumerMessages("BrokerB", clientB);
    MessageIdList msgsC = getConsumerMessages("BrokerC", clientC);
    msgsA.waitForMessagesToArrive(MESSAGE_COUNT);
    msgsB.waitForMessagesToArrive(MESSAGE_COUNT * 3);
    msgsC.waitForMessagesToArrive(MESSAGE_COUNT);
    assertEquals(MESSAGE_COUNT, msgsA.getMessageCount());
    assertEquals(MESSAGE_COUNT * 3, msgsB.getMessageCount());
    assertEquals(MESSAGE_COUNT, 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 3 with MessageIdList

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

the class ThreeBrokerTopicNetworkTest method testAllConnectedUsingMulticast.

/**
 * BrokerA <-> BrokerB <-> BrokerC
 */
public void testAllConnectedUsingMulticast() throws Exception {
    // Setup broker networks
    bridgeAllBrokers();
    startAllBrokers();
    // Setup destination
    Destination dest = createDestination("TEST.FOO", true);
    // Setup consumers
    MessageConsumer clientA = createConsumer("BrokerA", dest);
    MessageConsumer clientB = createConsumer("BrokerB", dest);
    MessageConsumer clientC = createConsumer("BrokerC", dest);
    // let consumers propagate around the network
    Thread.sleep(2000);
    // Send messages
    sendMessages("BrokerA", dest, MESSAGE_COUNT);
    sendMessages("BrokerB", dest, MESSAGE_COUNT);
    sendMessages("BrokerC", dest, MESSAGE_COUNT);
    // Get message count
    MessageIdList msgsA = getConsumerMessages("BrokerA", clientA);
    MessageIdList msgsB = getConsumerMessages("BrokerB", clientB);
    MessageIdList msgsC = getConsumerMessages("BrokerC", clientC);
    msgsA.waitForMessagesToArrive(MESSAGE_COUNT * 3);
    msgsB.waitForMessagesToArrive(MESSAGE_COUNT * 3);
    msgsC.waitForMessagesToArrive(MESSAGE_COUNT * 3);
    assertEquals(MESSAGE_COUNT * 3, msgsA.getMessageCount());
    assertEquals(MESSAGE_COUNT * 3, msgsB.getMessageCount());
    assertEquals(MESSAGE_COUNT * 3, 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 4 with MessageIdList

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

the class ThreeBrokerTopicNetworkTest method testBAandBCbrokerNetwork.

/**
 * BrokerA <- BrokerB -> BrokerC
 */
public void testBAandBCbrokerNetwork() throws Exception {
    // Setup broker networks
    bridgeBrokers("BrokerB", "BrokerA");
    bridgeBrokers("BrokerB", "BrokerC");
    startAllBrokers();
    // Setup destination
    Destination dest = createDestination("TEST.FOO", true);
    // Setup consumers
    MessageConsumer clientA = createConsumer("BrokerA", dest);
    MessageConsumer clientB = createConsumer("BrokerB", dest);
    MessageConsumer clientC = createConsumer("BrokerC", dest);
    // let consumers propagate around the network
    Thread.sleep(2000);
    // Send messages
    sendMessages("BrokerA", dest, MESSAGE_COUNT);
    sendMessages("BrokerB", dest, MESSAGE_COUNT);
    sendMessages("BrokerC", dest, MESSAGE_COUNT);
    // Get message count
    MessageIdList msgsA = getConsumerMessages("BrokerA", clientA);
    MessageIdList msgsB = getConsumerMessages("BrokerB", clientB);
    MessageIdList msgsC = getConsumerMessages("BrokerC", clientC);
    msgsA.waitForMessagesToArrive(MESSAGE_COUNT * 2);
    msgsB.waitForMessagesToArrive(MESSAGE_COUNT);
    msgsC.waitForMessagesToArrive(MESSAGE_COUNT * 2);
    assertEquals(MESSAGE_COUNT * 2, msgsA.getMessageCount());
    assertEquals(MESSAGE_COUNT, msgsB.getMessageCount());
    assertEquals(MESSAGE_COUNT * 2, 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 5 with MessageIdList

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

the class TopicReplicationTest method testReplication.

public void testReplication() throws Exception {
    createBroker(new ClassPathResource("org/apache/activemq/usecases/replication-broker1.xml"));
    createBroker(new ClassPathResource("org/apache/activemq/usecases/replication-broker2.xml"));
    createBroker(new ClassPathResource("org/apache/activemq/usecases/replication-broker3.xml"));
    createBroker(new ClassPathResource("org/apache/activemq/usecases/replication-broker4.xml"));
    brokers.get("replication-broker1").broker.waitUntilStarted();
    brokers.get("replication-broker2").broker.waitUntilStarted();
    brokers.get("replication-broker3").broker.waitUntilStarted();
    brokers.get("replication-broker4").broker.waitUntilStarted();
    Destination dest = createDestination("replication", true);
    // Setup consumers
    MessageConsumer clientA = createConsumer("replication-broker2", dest);
    MessageConsumer clientB = createConsumer("replication-broker3", dest);
    MessageConsumer clientC = createConsumer("replication-broker4", dest);
    MessageConsumer clientD = createConsumer("replication-broker4", dest);
    // let consumers propagate around the network
    Thread.sleep(2000);
    // Get message count
    MessageIdList msgsA = getConsumerMessages("replication-broker2", clientA);
    MessageIdList msgsB = getConsumerMessages("replication-broker3", clientB);
    MessageIdList msgsC = getConsumerMessages("replication-broker4", clientC);
    MessageIdList msgsD = getConsumerMessages("replication-broker4", clientD);
    // send messages to broker1
    sendMessages("replication-broker1", dest, MSG_COUNT);
    msgsA.waitForMessagesToArrive(MSG_COUNT);
    msgsB.waitForMessagesToArrive(MSG_COUNT);
    msgsC.waitForMessagesToArrive(MSG_COUNT);
    msgsD.waitForMessagesToArrive(MSG_COUNT);
    assertEquals(MSG_COUNT, msgsA.getMessageCount());
    assertEquals(MSG_COUNT, msgsB.getMessageCount());
    assertEquals(MSG_COUNT, msgsC.getMessageCount());
    assertEquals(MSG_COUNT, msgsD.getMessageCount());
    // send messages to broker4
    sendMessages("replication-broker4", dest, MSG_COUNT);
    msgsA.waitForMessagesToArrive(2 * MSG_COUNT);
    msgsB.waitForMessagesToArrive(2 * MSG_COUNT);
    msgsC.waitForMessagesToArrive(2 * MSG_COUNT);
    msgsD.waitForMessagesToArrive(2 * MSG_COUNT);
    assertEquals(2 * MSG_COUNT, msgsA.getMessageCount());
    assertEquals(2 * MSG_COUNT, msgsB.getMessageCount());
    assertEquals(2 * MSG_COUNT, msgsC.getMessageCount());
    assertEquals(2 * MSG_COUNT, msgsD.getMessageCount());
    // send messages to broker3
    sendMessages("replication-broker3", dest, MSG_COUNT);
    msgsA.waitForMessagesToArrive(3 * MSG_COUNT);
    msgsB.waitForMessagesToArrive(3 * MSG_COUNT);
    msgsC.waitForMessagesToArrive(3 * MSG_COUNT);
    msgsD.waitForMessagesToArrive(3 * MSG_COUNT);
    assertEquals(3 * MSG_COUNT, msgsA.getMessageCount());
    assertEquals(3 * MSG_COUNT, msgsB.getMessageCount());
    assertEquals(3 * MSG_COUNT, msgsC.getMessageCount());
    assertEquals(3 * MSG_COUNT, msgsD.getMessageCount());
    // send messages to broker2
    sendMessages("replication-broker2", dest, MSG_COUNT);
    msgsA.waitForMessagesToArrive(4 * MSG_COUNT);
    msgsB.waitForMessagesToArrive(4 * MSG_COUNT);
    msgsC.waitForMessagesToArrive(4 * MSG_COUNT);
    msgsD.waitForMessagesToArrive(4 * MSG_COUNT);
    assertEquals(4 * MSG_COUNT, msgsA.getMessageCount());
    assertEquals(4 * MSG_COUNT, msgsB.getMessageCount());
    assertEquals(4 * MSG_COUNT, msgsC.getMessageCount());
    assertEquals(4 * MSG_COUNT, msgsD.getMessageCount());
}
Also used : Destination(javax.jms.Destination) MessageConsumer(javax.jms.MessageConsumer) MessageIdList(org.apache.activemq.util.MessageIdList) ClassPathResource(org.springframework.core.io.ClassPathResource)

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