Search in sources :

Example 26 with MessageIdList

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

the class BacklogNetworkCrossTalkTest method testProduceConsume.

public void testProduceConsume() throws Exception {
    createBroker("A");
    createBroker("B");
    NetworkConnector nc = bridgeBrokers("A", "B");
    nc.setDuplex(true);
    nc.setDispatchAsync(false);
    startAllBrokers();
    waitForBridgeFormation();
    final int numMessages = 10000;
    // Create queue
    ActiveMQDestination destA = createDestination("AAA", false);
    sendMessages("A", destA, numMessages);
    ActiveMQDestination destB = createDestination("BBB", false);
    sendMessages("B", destB, numMessages);
    // consume across network
    LOG.info("starting consumers..");
    // Setup consumers
    MessageConsumer clientA = createConsumer("A", destB);
    // Setup consumers
    MessageConsumer clientB = createConsumer("B", destA);
    final long maxWait = 5 * 60 * 1000L;
    MessageIdList listA = getConsumerMessages("A", clientA);
    listA.setMaximumDuration(maxWait);
    listA.waitForMessagesToArrive(numMessages);
    MessageIdList listB = getConsumerMessages("B", clientB);
    listB.setMaximumDuration(maxWait);
    listB.waitForMessagesToArrive(numMessages);
    assertEquals("got all on A" + listA.getMessageCount(), numMessages, listA.getMessageCount());
    assertEquals("got all on B" + listB.getMessageCount(), numMessages, listB.getMessageCount());
}
Also used : MessageConsumer(javax.jms.MessageConsumer) NetworkConnector(org.apache.activemq.network.NetworkConnector) MessageIdList(org.apache.activemq.util.MessageIdList) ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination)

Example 27 with MessageIdList

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

the class BrowseOverNetworkTest method testBrowse.

public void testBrowse() throws Exception {
    createBroker(new URI("broker:(tcp://localhost:61617)/BrokerB?persistent=false&useJmx=false"));
    createBroker(new URI("broker:(tcp://localhost:61616)/BrokerA?persistent=false&useJmx=false"));
    bridgeBrokers("BrokerA", "BrokerB");
    startAllBrokers();
    Destination dest = createDestination("TEST.FOO", false);
    sendMessages("BrokerA", dest, MESSAGE_COUNT);
    Thread.sleep(1000);
    int browsed = browseMessages("BrokerB", dest);
    Thread.sleep(1000);
    MessageConsumer clientA = createConsumer("BrokerA", dest);
    MessageIdList msgsA = getConsumerMessages("BrokerA", clientA);
    msgsA.waitForMessagesToArrive(MESSAGE_COUNT);
    Thread.sleep(1000);
    MessageConsumer clientB = createConsumer("BrokerB", dest);
    MessageIdList msgsB = getConsumerMessages("BrokerB", clientB);
    msgsB.waitForMessagesToArrive(MESSAGE_COUNT);
    LOG.info("A+B: " + msgsA.getMessageCount() + "+" + msgsB.getMessageCount());
    assertEquals("Consumer on Broker A, should've consumed all messages", MESSAGE_COUNT, msgsA.getMessageCount());
    assertEquals("Broker B shouldn't get any messages", 0, browsed);
}
Also used : ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination) Destination(javax.jms.Destination) MessageConsumer(javax.jms.MessageConsumer) MessageIdList(org.apache.activemq.util.MessageIdList) URI(java.net.URI)

Example 28 with MessageIdList

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

the class MulticastDiscoveryOnFaultyNetworkTest method testSendOnAFaultyTransport.

public void testSendOnAFaultyTransport() 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.setMaximumDuration(200000L);
    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)

Example 29 with MessageIdList

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

the class JmsMultipleClientsTestSupport method assertConsumerReceivedAtMostXMessages.

protected void assertConsumerReceivedAtMostXMessages(MessageConsumer consumer, int msgCount) {
    MessageIdList messageIdList = consumers.get(consumer);
    messageIdList.assertAtMostMessagesReceived(msgCount);
}
Also used : MessageIdList(org.apache.activemq.util.MessageIdList)

Example 30 with MessageIdList

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

the class JmsMultipleClientsTestSupport method assertConsumerReceivedXMessages.

protected void assertConsumerReceivedXMessages(MessageConsumer consumer, int msgCount) {
    MessageIdList messageIdList = consumers.get(consumer);
    messageIdList.assertMessagesReceivedNoWait(msgCount);
}
Also used : 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