use of org.apache.activemq.util.MessageIdList in project activemq-artemis by apache.
the class ThreeBrokerQueueNetworkTest method testMigrateConsumer.
// use case: for maintenance, migrate consumers and producers from one
// node in the network to another so node can be replaced/updated
public void testMigrateConsumer() throws Exception {
boolean suppressQueueDuplicateSubscriptions = true;
boolean decreaseNetworkConsumerPriority = true;
bridgeAllBrokers("default", 3, suppressQueueDuplicateSubscriptions, decreaseNetworkConsumerPriority);
startAllBrokers();
waitForBridgeFormation();
// Setup destination
Destination dest = createDestination("TEST.FOO", false);
// Setup consumers
LOG.info("Consumer on A");
MessageConsumer clientA = createConsumer("BrokerA", dest);
// ensure advisors have percolated
Thread.sleep(2000);
LOG.info("Consumer on B");
int messageCount = 2000;
CountDownLatch messagesReceived = new CountDownLatch(messageCount);
MessageConsumer clientB = createConsumer("BrokerB", dest, messagesReceived);
// make the consumer slow so that any network consumer has a chance, even
// if it has a lower priority
MessageIdList msgs = getConsumerMessages("BrokerB", clientB);
msgs.setProcessingDelay(10);
// ensure advisors have percolated
Thread.sleep(2000);
LOG.info("Close consumer on A");
clientA.close();
// ensure advisors have percolated
Thread.sleep(2000);
LOG.info("Send to B");
sendMessages("BrokerB", dest, messageCount);
// Let's try to wait for any messages.
assertTrue("messages are received within limit", messagesReceived.await(60, TimeUnit.SECONDS));
assertEquals(messageCount, msgs.getMessageCount());
}
use of org.apache.activemq.util.MessageIdList in project activemq-artemis by apache.
the class ThreeBrokerQueueNetworkTest method testABandCBbrokerNetwork.
/**
* BrokerA -> BrokerB <- BrokerC
*/
public void testABandCBbrokerNetwork() throws Exception {
// Setup broker networks
bridgeBrokers("BrokerA", "BrokerB");
bridgeBrokers("BrokerC", "BrokerB");
startAllBrokers();
waitForBridgeFormation();
// Setup destination
Destination dest = createDestination("TEST.FOO", false);
// Setup consumers
MessageConsumer clientB = createConsumer("BrokerB", dest);
// Send messages
sendMessages("BrokerA", dest, MESSAGE_COUNT);
sendMessages("BrokerC", dest, MESSAGE_COUNT);
// Get message count
MessageIdList msgsB = getConsumerMessages("BrokerB", clientB);
msgsB.waitForMessagesToArrive(MESSAGE_COUNT * 2);
assertEquals(MESSAGE_COUNT * 2, msgsB.getMessageCount());
}
use of org.apache.activemq.util.MessageIdList in project activemq-artemis by apache.
the class StaticNetworkTest method testStaticNetwork.
public void testStaticNetwork() throws Exception {
// Setup destination
ActiveMQDestination dest = createDestination("TEST", false);
ActiveMQDestination dest1 = createDestination("TEST1", false);
NetworkConnector bridgeAB = bridgeBrokers("BrokerA", "BrokerB", true);
bridgeAB.addStaticallyIncludedDestination(dest);
bridgeAB.setStaticBridge(true);
startAllBrokers();
waitForBridgeFormation();
MessageConsumer consumer1 = createConsumer("BrokerB", dest);
MessageConsumer consumer2 = createConsumer("BrokerB", dest1);
Thread.sleep(1000);
sendMessages("BrokerA", dest, 1);
sendMessages("BrokerA", dest1, 1);
MessageIdList msgs1 = getConsumerMessages("BrokerB", consumer1);
MessageIdList msgs2 = getConsumerMessages("BrokerB", consumer2);
msgs1.waitForMessagesToArrive(1);
Thread.sleep(1000);
assertEquals(1, msgs1.getMessageCount());
assertEquals(0, msgs2.getMessageCount());
}
use of org.apache.activemq.util.MessageIdList in project activemq-artemis by apache.
the class TwoBrokerMessageNotSentToRemoteWhenNoConsumerTest method testRemoteBrokerHasNoConsumer.
/**
* BrokerA -> BrokerB
*/
public void testRemoteBrokerHasNoConsumer() throws Exception {
// Setup broker networks
bridgeBrokers("BrokerA", "BrokerB");
startAllBrokers();
// Setup destination
Destination dest = createDestination("TEST.FOO", true);
// Setup consumers
MessageConsumer clientA = createConsumer("BrokerA", dest);
// Send messages
sendMessages("BrokerA", dest, MESSAGE_COUNT);
// Get message count
MessageIdList msgsA = getConsumerMessages("BrokerA", clientA);
msgsA.waitForMessagesToArrive(MESSAGE_COUNT);
assertEquals(MESSAGE_COUNT, msgsA.getMessageCount());
}
use of org.apache.activemq.util.MessageIdList in project activemq-artemis by apache.
the class TwoBrokerMessageNotSentToRemoteWhenNoConsumerTest method testDuplexStaticRemoteBrokerHasNoConsumer.
/**
* BrokerA -> BrokerB && BrokerB -> BrokerA
*/
public void testDuplexStaticRemoteBrokerHasNoConsumer() throws Exception {
// Setup broker networks
boolean dynamicOnly = true;
int networkTTL = 2;
boolean conduit = true;
bridgeBrokers("BrokerA", "BrokerB", dynamicOnly, networkTTL, conduit);
bridgeBrokers("BrokerB", "BrokerA", dynamicOnly, networkTTL, conduit);
startAllBrokers();
// Setup destination
Destination dest = createDestination("TEST.FOO", false);
// Setup consumers
MessageConsumer clientA = createConsumer("BrokerA", dest);
Thread.sleep(2 * 1000);
int messageCount = 2000;
// Send messages
sendMessages("BrokerA", dest, messageCount);
// Get message count
MessageIdList msgsA = getConsumerMessages("BrokerA", clientA);
msgsA.waitForMessagesToArrive(messageCount);
assertEquals(messageCount, msgsA.getMessageCount());
}
Aggregations