use of org.apache.activemq.util.MessageIdList in project activemq-artemis by apache.
the class ThreeBrokerTopicNetworkTest method testAllConnectedBrokerNetworkDurableSubTTL.
public void testAllConnectedBrokerNetworkDurableSubTTL() throws Exception {
int networkTTL = 2;
boolean conduitSubs = true;
// Setup ring broker network
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);
startAllBrokers();
// Setup destination
Destination dest = createDestination("TEST.FOO", true);
// Setup consumers
MessageConsumer clientA = createDurableSubscriber("BrokerA", (Topic) dest, "clientA");
MessageConsumer clientB = createDurableSubscriber("BrokerB", (Topic) dest, "clientB");
MessageConsumer clientC = createDurableSubscriber("BrokerC", (Topic) dest, "clientC");
// 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());
}
use of org.apache.activemq.util.MessageIdList in project activemq-artemis by apache.
the class ThreeBrokerVirtualTopicNetworkTest method testNetworkVirtualTopic.
public void testNetworkVirtualTopic() throws Exception {
int networkTTL = 6;
boolean conduitSubs = true;
// Setup broker networks
bridgeAndConfigureBrokers("BrokerA", "BrokerB", dynamicOnly, networkTTL, conduitSubs);
bridgeAndConfigureBrokers("BrokerA", "BrokerC", dynamicOnly, networkTTL, conduitSubs);
bridgeAndConfigureBrokers("BrokerB", "BrokerA", dynamicOnly, networkTTL, conduitSubs);
bridgeAndConfigureBrokers("BrokerB", "BrokerC", dynamicOnly, networkTTL, conduitSubs);
bridgeAndConfigureBrokers("BrokerC", "BrokerA", dynamicOnly, networkTTL, conduitSubs);
bridgeAndConfigureBrokers("BrokerC", "BrokerB", dynamicOnly, networkTTL, conduitSubs);
startAllBrokers();
waitForBridgeFormation();
// Setup destination
Destination dest = createDestination("TEST.FOO", true);
// Setup consumers
MessageConsumer clientA = createConsumer("BrokerA", createDestination("Consumer.A.TEST.FOO", false));
MessageConsumer clientB = createConsumer("BrokerB", createDestination("Consumer.B.TEST.FOO", false));
MessageConsumer clientC = createConsumer("BrokerC", createDestination("Consumer.C.TEST.FOO", false));
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());
// restart to ensure no hanging messages
LOG.info("Restarting brokerA");
BrokerItem brokerItem = brokers.remove("BrokerA");
if (brokerItem != null) {
brokerItem.destroy();
}
BrokerService restartedBroker = createAndConfigureBroker(new URI("broker:(tcp://localhost:61616)/BrokerA?useJmx=false"));
bridgeAndConfigureBrokers("BrokerA", "BrokerB", dynamicOnly, networkTTL, conduitSubs);
bridgeAndConfigureBrokers("BrokerA", "BrokerC", dynamicOnly, networkTTL, conduitSubs);
restartedBroker.start();
waitForBridgeFormation();
clientA = createConsumer("BrokerA", createDestination("Consumer.A.TEST.FOO", false));
LOG.info("recreated clientA");
Thread.sleep(2000);
sendMessages("BrokerA", dest, 10);
msgsA = getConsumerMessages("BrokerA", clientA);
msgsA.waitForMessagesToArrive(10);
msgsB.waitForMessagesToArrive(11);
msgsC.waitForMessagesToArrive(11);
// ensure we don't get any more messages
Thread.sleep(2000);
LOG.info("MessagesA: " + msgsA.getMessageIds());
assertEquals(10, msgsA.getMessageCount());
assertEquals(11, msgsB.getMessageCount());
assertEquals(11, msgsC.getMessageCount());
// restart to ensure no hanging messages
LOG.info("Restarting brokerA again");
brokerItem = brokers.remove("BrokerA");
if (brokerItem != null) {
brokerItem.destroy();
}
restartedBroker = createAndConfigureBroker(new URI("broker:(tcp://localhost:61616)/BrokerA?useJmx=false"));
bridgeAndConfigureBrokers("BrokerA", "BrokerB", dynamicOnly, networkTTL, conduitSubs);
bridgeAndConfigureBrokers("BrokerA", "BrokerC", dynamicOnly, networkTTL, conduitSubs);
restartedBroker.start();
waitForBridgeFormation();
clientA = createConsumer("BrokerA", createDestination("Consumer.A.TEST.FOO", false));
LOG.info("recreated clientA again");
Thread.sleep(2000);
msgsA = getConsumerMessages("BrokerA", clientA);
// ensure we don't get any more messages
Thread.sleep(5000);
LOG.info("Extra MessagesA: " + msgsA.getMessageIds());
assertEquals(0, msgsA.getMessageCount());
assertEquals(11, msgsB.getMessageCount());
assertEquals(11, msgsC.getMessageCount());
}
use of org.apache.activemq.util.MessageIdList in project activemq-artemis by apache.
the class SingleBrokerVirtualDestinationsWithWildcardTest method sendReceive.
public void sendReceive(String dest1, boolean topic1, String dest2, boolean topic2, int send, int expected) throws Exception {
MessageConsumer client = createConsumer("BrokerA", createDestination(dest2, topic2));
Thread.sleep(1000);
sendMessages("BrokerA", createDestination(dest1, topic1), send);
MessageIdList msgs = getConsumerMessages("BrokerA", client);
msgs.setMaximumDuration(1000);
assertEquals(expected, msgs.getMessageCount());
client.close();
Thread.sleep(500);
}
use of org.apache.activemq.util.MessageIdList in project activemq-artemis by apache.
the class ThreeBrokerQueueNetworkTest method testAllConnectedWithSpare.
public void testAllConnectedWithSpare() throws Exception {
bridgeAllBrokers("default", 3, false);
startAllBrokers();
waitForBridgeFormation();
// Setup destination
Destination dest = createDestination("TEST.FOO", false);
// Setup consumers
int messageCount = 2000;
CountDownLatch messagesReceived = new CountDownLatch(messageCount);
MessageConsumer clientA = createConsumer("BrokerA", dest, messagesReceived);
// ensure advisory percolation.
Thread.sleep(2000);
// Send messages
sendMessages("BrokerB", dest, messageCount);
assertTrue("messaged received within time limit", messagesReceived.await(30, TimeUnit.SECONDS));
// Get message count
MessageIdList msgsA = getConsumerMessages("BrokerA", clientA);
assertEquals(messageCount, msgsA.getMessageCount());
}
use of org.apache.activemq.util.MessageIdList in project activemq-artemis by apache.
the class ThreeBrokerQueueNetworkTest method testAllConnectedUsingMulticastProducerConsumerOnA.
public void testAllConnectedUsingMulticastProducerConsumerOnA() throws Exception {
bridgeAllBrokers("default", 3, false);
startAllBrokers();
waitForBridgeFormation();
// Setup destination
Destination dest = createDestination("TEST.FOO", false);
// Setup consumers
int messageCount = 2000;
CountDownLatch messagesReceived = new CountDownLatch(messageCount);
MessageConsumer clientA = createConsumer("BrokerA", dest, messagesReceived);
// Let's try to wait for advisory percolation.
Thread.sleep(1000);
// Send messages
sendMessages("BrokerA", dest, messageCount);
assertTrue(messagesReceived.await(30, TimeUnit.SECONDS));
// Get message count
MessageIdList msgsA = getConsumerMessages("BrokerA", clientA);
assertEquals(messageCount, msgsA.getMessageCount());
}
Aggregations