use of org.apache.activemq.util.MessageIdList in project activemq-artemis by apache.
the class SimpleDispatchPolicyTest method assertOneConsumerReceivedAllMessages.
public void assertOneConsumerReceivedAllMessages(int messageCount) throws Exception {
boolean found = false;
for (Iterator<MessageConsumer> i = consumers.keySet().iterator(); i.hasNext(); ) {
MessageIdList messageIdList = consumers.get(i.next());
int count = messageIdList.getMessageCount();
if (count > 0) {
if (found) {
fail("No other consumers should have received any messages");
} else {
assertEquals("Consumer should have received all messages.", messageCount, count);
found = true;
}
}
}
if (!found) {
fail("At least one consumer should have received all messages");
}
}
use of org.apache.activemq.util.MessageIdList in project activemq-artemis by apache.
the class StrictOrderDispatchPolicyTest method assertReceivedMessagesAreOrdered.
public void assertReceivedMessagesAreOrdered() throws Exception {
// If there is only one consumer, messages is definitely ordered
if (consumers.size() <= 1) {
return;
}
// Get basis of order
Iterator<MessageConsumer> i = consumers.keySet().iterator();
MessageIdList messageOrder = consumers.get(i.next());
for (; i.hasNext(); ) {
MessageIdList messageIdList = consumers.get(i.next());
assertTrue("Messages are not ordered.", messageOrder.equals(messageIdList));
}
}
use of org.apache.activemq.util.MessageIdList in project activemq-artemis by apache.
the class AbortSlowConsumer0Test method testAbortAlreadyClosingConsumers.
@Test
public void testAbortAlreadyClosingConsumers() throws Exception {
consumerCount = 1;
startConsumers(withPrefetch(2, destination));
for (MessageIdList list : consumers.values()) {
list.setProcessingDelay(6 * 1000);
}
for (Connection c : connections) {
c.setExceptionListener(this);
}
startProducers(destination, 100);
allMessagesList.waitForMessagesToArrive(consumerCount);
for (MessageConsumer consumer : consumers.keySet()) {
LOG.info("closing consumer: " + consumer);
// / will block waiting for on message till 6secs expire
consumer.close();
}
}
use of org.apache.activemq.util.MessageIdList in project activemq-artemis by apache.
the class MultiBrokersMultiClientsTest method testQueueAllConnected.
public void testQueueAllConnected() throws Exception {
bridgeAllBrokers();
startAllBrokers();
this.waitForBridgeFormation();
// Setup topic destination
Destination dest = createDestination("TEST.FOO", false);
CountDownLatch latch = new CountDownLatch(BROKER_COUNT * PRODUCER_COUNT * MESSAGE_COUNT);
// Setup consumers
for (int i = 1; i <= BROKER_COUNT; i++) {
for (int j = 0; j < CONSUMER_COUNT; j++) {
consumerMap.put("Consumer:" + i + ":" + j, createConsumer("Broker" + i, dest, latch));
}
}
// wait for consumers to get propagated
for (int i = 1; i <= BROKER_COUNT; i++) {
// all consumers on the remote brokers look like 1 consumer to the local broker.
assertConsumersConnect("Broker" + i, dest, (BROKER_COUNT - 1) + CONSUMER_COUNT, 65000);
}
// Send messages
for (int i = 1; i <= BROKER_COUNT; i++) {
for (int j = 0; j < PRODUCER_COUNT; j++) {
sendMessages("Broker" + i, dest, MESSAGE_COUNT);
}
}
// Wait for messages to be delivered
assertTrue("Missing " + latch.getCount() + " messages", latch.await(45, TimeUnit.SECONDS));
// Get message count
int totalMsg = 0;
for (int i = 1; i <= BROKER_COUNT; i++) {
for (int j = 0; j < CONSUMER_COUNT; j++) {
MessageIdList msgs = getConsumerMessages("Broker" + i, consumerMap.get("Consumer:" + i + ":" + j));
totalMsg += msgs.getMessageCount();
}
}
assertEquals(BROKER_COUNT * PRODUCER_COUNT * MESSAGE_COUNT, totalMsg);
assertNoUnhandeledExceptions();
}
use of org.apache.activemq.util.MessageIdList in project activemq-artemis by apache.
the class AbstractTwoBrokerNetworkConnectorWildcardIncludedDestinationTestSupport method sendReceive.
public void sendReceive(String broker1, String dest1, boolean topic1, String broker2, String dest2, boolean topic2, int send, int expected) throws Exception {
MessageConsumer client = createConsumer(broker2, createDestination(dest2, topic2));
Thread.sleep(2000);
sendMessages(broker1, createDestination(dest1, topic1), send);
MessageIdList msgs = getConsumerMessages(broker2, client);
msgs.setMaximumDuration(10000);
msgs.waitForMessagesToArrive(send);
assertEquals(expected, msgs.getMessageCount());
client.close();
Thread.sleep(1000);
}
Aggregations