Search in sources :

Example 36 with MessageIdList

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

the class AbortSlowConsumer2Test method testLittleSlowConsumerIsNotAborted.

@Test(timeout = 60 * 1000)
public void testLittleSlowConsumerIsNotAborted() throws Exception {
    startConsumers(destination);
    Entry<MessageConsumer, MessageIdList> consumertoAbort = consumers.entrySet().iterator().next();
    consumertoAbort.getValue().setProcessingDelay(500);
    for (Connection c : connections) {
        c.setExceptionListener(this);
    }
    startProducers(destination, 12);
    allMessagesList.waitForMessagesToArrive(10);
    allMessagesList.assertAtLeastMessagesReceived(10);
}
Also used : MessageConsumer(javax.jms.MessageConsumer) Connection(javax.jms.Connection) MessageIdList(org.apache.activemq.util.MessageIdList) Test(org.junit.Test)

Example 37 with MessageIdList

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

the class ThreeBrokerTopicNetworkTest method testABandBCbrokerNetworkWithSelectors.

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

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

the class ThreeBrokerTopicNetworkTest method testAllConnectedBrokerNetworkSingleProducerTTL.

public void testAllConnectedBrokerNetworkSingleProducerTTL() throws Exception {
    // duplicates are expected with ttl of 2 as each broker is connected to the next
    // but the dups are suppressed by the store and now also by the topic sub when enableAudit
    // default (true) is present in a matching destination policy entry
    int networkTTL = 2;
    boolean conduitSubs = true;
    // Setup ring broker networks
    bridgeBrokers("BrokerA", "BrokerB", dynamicOnly, networkTTL, conduitSubs);
    bridgeBrokers("BrokerB", "BrokerA", dynamicOnly, networkTTL, conduitSubs);
    bridgeBrokers("BrokerB", "BrokerC", dynamicOnly, networkTTL, conduitSubs);
    bridgeBrokers("BrokerC", "BrokerB", dynamicOnly, networkTTL, conduitSubs);
    bridgeBrokers("BrokerA", "BrokerC", dynamicOnly, networkTTL, conduitSubs);
    bridgeBrokers("BrokerC", "BrokerA", dynamicOnly, networkTTL, conduitSubs);
    PolicyMap policyMap = new PolicyMap();
    // enable audit is on by default just need to give it matching policy entry
    // so it will be applied to the topic subscription
    policyMap.setDefaultEntry(new PolicyEntry());
    Collection<BrokerItem> brokerList = brokers.values();
    for (Iterator<BrokerItem> i = brokerList.iterator(); i.hasNext(); ) {
        BrokerService broker = i.next().broker;
        broker.setDestinationPolicy(policyMap);
        broker.setDeleteAllMessagesOnStartup(true);
    }
    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, 1);
    // Get message count
    MessageIdList msgsA = getConsumerMessages("BrokerA", clientA);
    MessageIdList msgsB = getConsumerMessages("BrokerB", clientB);
    MessageIdList msgsC = getConsumerMessages("BrokerC", clientC);
    msgsA.waitForMessagesToArrive(1);
    msgsB.waitForMessagesToArrive(1);
    msgsC.waitForMessagesToArrive(1);
    // ensure we don't get any more messages
    Thread.sleep(2000);
    assertEquals(1, msgsA.getMessageCount());
    assertEquals(1, msgsB.getMessageCount());
    assertEquals(1, msgsC.getMessageCount());
}
Also used : ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination) Destination(javax.jms.Destination) MessageConsumer(javax.jms.MessageConsumer) PolicyMap(org.apache.activemq.broker.region.policy.PolicyMap) MessageIdList(org.apache.activemq.util.MessageIdList) PolicyEntry(org.apache.activemq.broker.region.policy.PolicyEntry) BrokerService(org.apache.activemq.broker.BrokerService)

Example 39 with MessageIdList

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

the class ThreeBrokerTopicNetworkTest method testABandBCbrokerNetwork.

/**
 * BrokerA -> BrokerB -> BrokerC
 */
public void testABandBCbrokerNetwork() throws Exception {
    // Setup broker networks
    bridgeBrokers("BrokerA", "BrokerB");
    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);
    msgsB.waitForMessagesToArrive(MESSAGE_COUNT * 2);
    msgsC.waitForMessagesToArrive(MESSAGE_COUNT * 2);
    assertEquals(MESSAGE_COUNT, msgsA.getMessageCount());
    assertEquals(MESSAGE_COUNT * 2, msgsB.getMessageCount());
    assertEquals(MESSAGE_COUNT * 2, msgsC.getMessageCount());
    assertEquals("Correct forwards from A", MESSAGE_COUNT, brokers.get("BrokerA").broker.getDestination(ActiveMQDestination.transform(dest)).getDestinationStatistics().getForwards().getCount());
}
Also used : ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination) Destination(javax.jms.Destination) MessageConsumer(javax.jms.MessageConsumer) MessageIdList(org.apache.activemq.util.MessageIdList)

Example 40 with MessageIdList

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

the class ThreeBrokerTopicNetworkTest 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();
    // 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)

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