Search in sources :

Example 11 with MessageIdList

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

the class TwoBrokerNetworkLoadBalanceTest method testLoadBalancing.

public void testLoadBalancing() throws Exception {
    bridgeBrokers("BrokerA", "BrokerB");
    bridgeBrokers("BrokerB", "BrokerA");
    startAllBrokers();
    waitForBridgeFormation();
    // Setup destination
    Destination dest = createDestination("TEST.FOO", false);
    // Setup consumers
    MessageConsumer clientA = createConsumer("BrokerA", dest);
    // Setup consumers
    MessageConsumer clientB = createConsumer("BrokerB", dest);
    // Send messages
    sendMessages("BrokerA", dest, 5000);
    // Send messages
    sendMessages("BrokerB", dest, 1000);
    // Get message count
    final MessageIdList msgsA = getConsumerMessages("BrokerA", clientA);
    final MessageIdList msgsB = getConsumerMessages("BrokerB", clientB);
    Wait.waitFor(new Wait.Condition() {

        @Override
        public boolean isSatisified() throws Exception {
            return msgsA.getMessageCount() + msgsB.getMessageCount() == 6000;
        }
    });
    LOG.info("A got: " + msgsA.getMessageCount());
    LOG.info("B got: " + msgsB.getMessageCount());
    assertTrue("B got is fair share: " + msgsB.getMessageCount(), msgsB.getMessageCount() > 2000);
}
Also used : Destination(javax.jms.Destination) MessageConsumer(javax.jms.MessageConsumer) MessageIdList(org.apache.activemq.util.MessageIdList) Wait(org.apache.activemq.util.Wait)

Example 12 with MessageIdList

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

the class TwoBrokerVirtualDestDinamicallyIncludedDestTest method testVirtualDestinationsDinamicallyIncludedBehavior2.

/**
 * BrokerA -> BrokerB && BrokerB -> BrokerA
 */
public void testVirtualDestinationsDinamicallyIncludedBehavior2() throws Exception {
    startAllBrokers();
    // Setup destination
    Destination dest = createDestination("global.test", true);
    // Setup consumers
    // MessageConsumer clientB1 = createConsumer("BrokerB", dest);
    MessageConsumer clientB2 = createConsumer("BrokerB", createDestination("Consumer.foo-bar.global.test", false));
    Thread.sleep(2 * 1000);
    // Send messages
    sendMessages("BrokerA", dest, MESSAGE_COUNT);
    // Get message count
    MessageIdList msgsB2 = getConsumerMessages("BrokerB", clientB2);
    msgsB2.waitForMessagesToArrive(MESSAGE_COUNT);
    assertEquals(MESSAGE_COUNT, msgsB2.getMessageCount());
}
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)

Example 13 with MessageIdList

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

the class TwoBrokerVirtualDestDinamicallyIncludedDestTest method testVirtualDestinationsDinamicallyIncludedBehavior1.

/**
 * BrokerA -> BrokerB && BrokerB -> BrokerA
 */
public void testVirtualDestinationsDinamicallyIncludedBehavior1() throws Exception {
    startAllBrokers();
    // Setup destination
    Destination dest = createDestination("global.test", true);
    // Setup consumers
    MessageConsumer clientB1 = createConsumer("BrokerB", dest);
    MessageConsumer clientB2 = createConsumer("BrokerB", createDestination("Consumer.foo-bar.global.test", false));
    Thread.sleep(2 * 1000);
    int messageCount = MESSAGE_COUNT;
    // Send messages
    sendMessages("BrokerA", dest, messageCount);
    // Get message count
    MessageIdList msgsB1 = getConsumerMessages("BrokerB", clientB1);
    msgsB1.waitForMessagesToArrive(messageCount);
    assertEquals(messageCount, msgsB1.getMessageCount());
    MessageIdList msgsB2 = getConsumerMessages("BrokerB", clientB2);
    msgsB2.waitForMessagesToArrive(messageCount);
    assertEquals(messageCount, msgsB2.getMessageCount());
}
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)

Example 14 with MessageIdList

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

the class TwoBrokerVirtualDestDinamicallyIncludedDestTest method testTopicDinamicallyIncludedBehavior.

/**
 * BrokerA -> BrokerB && BrokerB -> BrokerA
 */
public void testTopicDinamicallyIncludedBehavior() throws Exception {
    startAllBrokers();
    // Setup destination
    Destination dest = createDestination("test", true);
    // Setup consumers
    MessageConsumer clientA = createConsumer("BrokerA", dest);
    MessageConsumer clientB = createConsumer("BrokerB", dest);
    Thread.sleep(2 * 1000);
    // Send messages
    sendMessages("BrokerA", dest, MESSAGE_COUNT);
    // Get message count
    MessageIdList msgsA = getConsumerMessages("BrokerA", clientA);
    msgsA.waitForMessagesToArrive(MESSAGE_COUNT);
    assertEquals(MESSAGE_COUNT, msgsA.getMessageCount());
    MessageIdList msgsB = getConsumerMessages("BrokerB", clientB);
    msgsB.waitForMessagesToArrive(MESSAGE_COUNT);
    assertEquals(0, msgsB.getMessageCount());
}
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)

Example 15 with MessageIdList

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

the class TwoBrokerMessageNotSentToRemoteWhenNoConsumerTest method testRemoteBrokerHasConsumer.

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