Search in sources :

Example 46 with MessageIdList

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

the class ThreeBrokerQueueNetworkTest method testABandBCbrokerNetwork.

/**
 * BrokerA -> BrokerB -> BrokerC
 */
public void testABandBCbrokerNetwork() throws Exception {
    // Setup broker networks
    bridgeBrokers("BrokerA", "BrokerB");
    bridgeBrokers("BrokerB", "BrokerC");
    startAllBrokers();
    waitForBridgeFormation();
    // Setup destination
    Destination dest = createDestination("TEST.FOO", false);
    // Setup consumers
    MessageConsumer clientC = createConsumer("BrokerC", dest);
    // Send messages
    sendMessages("BrokerA", dest, MESSAGE_COUNT);
    // Let's try to wait for any messages. Should be none.
    Thread.sleep(1000);
    // Get message count
    MessageIdList msgsC = getConsumerMessages("BrokerC", clientC);
    assertEquals(0, 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 47 with MessageIdList

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

the class ThreeBrokerQueueNetworkTest method testBAandBCbrokerNetwork.

/**
 * BrokerA <- BrokerB -> BrokerC
 */
public void testBAandBCbrokerNetwork() throws Exception {
    // Setup broker networks
    bridgeBrokers("BrokerB", "BrokerA");
    bridgeBrokers("BrokerB", "BrokerC");
    startAllBrokers();
    waitForBridgeFormation();
    // Setup destination
    Destination dest = createDestination("TEST.FOO", false);
    // Setup consumers
    MessageConsumer clientA = createConsumer("BrokerA", dest);
    MessageConsumer clientC = createConsumer("BrokerC", dest);
    // et subscriptions get propagated
    Thread.sleep(2000);
    // Send messages
    sendMessages("BrokerB", dest, MESSAGE_COUNT);
    // Let's try to wait for any messages.
    Thread.sleep(1000);
    // Get message count
    MessageIdList msgsA = getConsumerMessages("BrokerA", clientA);
    MessageIdList msgsC = getConsumerMessages("BrokerC", clientC);
    // Total received should be 100
    assertEquals(MESSAGE_COUNT, msgsA.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 48 with MessageIdList

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

the class ThreeBrokerQueueNetworkTest method testBAandBCbrokerNetworkWithSelectorsSubscribeFirst.

/**
 * BrokerA <- BrokerB -> BrokerC
 */
public void testBAandBCbrokerNetworkWithSelectorsSubscribeFirst() throws Exception {
    // Setup broker networks
    bridgeBrokers("BrokerB", "BrokerA", true, 1, false);
    bridgeBrokers("BrokerB", "BrokerC", true, 1, false);
    startAllBrokers();
    waitForBridgeFormation();
    // Setup destination
    Destination dest = createDestination("TEST.FOO", false);
    // Setup consumers
    MessageConsumer clientA = createConsumer("BrokerA", dest, "broker = 'BROKER_A'");
    MessageConsumer clientC = createConsumer("BrokerC", dest, "broker = 'BROKER_C'");
    // et subscriptions get propagated
    Thread.sleep(2000);
    // Send messages for broker A
    HashMap<String, Object> props = new HashMap<>();
    props.put("broker", "BROKER_A");
    sendMessages("BrokerB", dest, MESSAGE_COUNT, props);
    // Send messages for broker C
    props.clear();
    props.put("broker", "BROKER_C");
    sendMessages("BrokerB", dest, MESSAGE_COUNT, props);
    // Let's try to wait for any messages.
    Thread.sleep(1000);
    // Get message count
    MessageIdList msgsA = getConsumerMessages("BrokerA", clientA);
    MessageIdList msgsC = getConsumerMessages("BrokerC", clientC);
    // Total received should be 100
    assertEquals(MESSAGE_COUNT, msgsA.getMessageCount());
    assertEquals(MESSAGE_COUNT, msgsC.getMessageCount());
}
Also used : ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination) Destination(javax.jms.Destination) MessageConsumer(javax.jms.MessageConsumer) HashMap(java.util.HashMap) MessageIdList(org.apache.activemq.util.MessageIdList)

Example 49 with MessageIdList

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

the class ThreeBrokerQueueNetworkTest method testBAandBCbrokerNetworkWithSelectorsSendFirst.

/**
 * BrokerA <- BrokerB -> BrokerC
 */
public void testBAandBCbrokerNetworkWithSelectorsSendFirst() throws Exception {
    // Setup broker networks
    bridgeBrokers("BrokerB", "BrokerA", true, 1, false);
    bridgeBrokers("BrokerB", "BrokerC", true, 1, false);
    startAllBrokers();
    waitForBridgeFormation();
    // Setup destination
    Destination dest = createDestination("TEST.FOO", false);
    // Send messages for broker A
    HashMap<String, Object> props = new HashMap<>();
    props.put("broker", "BROKER_A");
    sendMessages("BrokerB", dest, MESSAGE_COUNT, props);
    // Send messages for broker C
    props.clear();
    props.put("broker", "BROKER_C");
    sendMessages("BrokerB", dest, MESSAGE_COUNT, props);
    // Setup consumers
    MessageConsumer clientA = createConsumer("BrokerA", dest, "broker = 'BROKER_A'");
    MessageConsumer clientC = createConsumer("BrokerC", dest, "broker = 'BROKER_C'");
    // et subscriptions get propagated
    Thread.sleep(2000);
    // Let's try to wait for any messages.
    // Thread.sleep(1000);
    // Get message count
    MessageIdList msgsA = getConsumerMessages("BrokerA", clientA);
    MessageIdList msgsC = getConsumerMessages("BrokerC", clientC);
    // Total received should be 100
    assertEquals(MESSAGE_COUNT, msgsA.getMessageCount());
    assertEquals(MESSAGE_COUNT, msgsC.getMessageCount());
}
Also used : ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination) Destination(javax.jms.Destination) MessageConsumer(javax.jms.MessageConsumer) HashMap(java.util.HashMap) MessageIdList(org.apache.activemq.util.MessageIdList)

Example 50 with MessageIdList

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

the class ThreeBrokerQueueNetworkTest method testAllConnectedBrokerNetwork.

/**
 * BrokerA <-> BrokerB <-> BrokerC
 */
public void testAllConnectedBrokerNetwork() throws Exception {
    // Setup broker networks
    bridgeBrokers("BrokerA", "BrokerB");
    bridgeBrokers("BrokerB", "BrokerA");
    bridgeBrokers("BrokerB", "BrokerC");
    bridgeBrokers("BrokerC", "BrokerB");
    bridgeBrokers("BrokerA", "BrokerC");
    bridgeBrokers("BrokerC", "BrokerA");
    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
    MessageIdList msgsA = getConsumerMessages("BrokerA", clientA);
    MessageIdList msgsB = getConsumerMessages("BrokerB", clientB);
    MessageIdList msgsC = getConsumerMessages("BrokerC", clientC);
    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)

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