use of org.apache.activemq.util.MessageIdList in project activemq-artemis by apache.
the class MessageReroutingTest method testMessageRerouting.
public void testMessageRerouting() throws Exception {
MessageConsumer consumer = createConsumer("broker-D", dest);
MessageIdList received = getConsumerMessages("broker-D", consumer);
// wait for subs to propagate
Thread.sleep(2000);
// send/receive messages
sendMessages("broker-A", dest, MESSAGE_COUNT);
received.waitForMessagesToArrive(MESSAGE_COUNT);
LOG.info("received " + received.getMessageCount() + " messages");
assertEquals(MESSAGE_COUNT, received.getMessageCount());
brokers.get("broker-B").broker.stop();
brokers.get("broker-B").broker.waitUntilStopped();
Thread.sleep(2000);
// ensure send/receive still works
sendMessages("broker-A", dest, MESSAGE_COUNT);
received.waitForMessagesToArrive(MESSAGE_COUNT);
LOG.info("received " + received.getMessageCount() + " messages");
assertTrue("Didn't receive any more messages " + received.getMessageCount(), received.getMessageCount() > MESSAGE_COUNT);
}
use of org.apache.activemq.util.MessageIdList in project activemq-artemis by apache.
the class PeerTransportTest method setUp.
@Override
protected void setUp() throws Exception {
connections = new Connection[NUMBER_IN_CLUSTER];
producers = new MessageProducer[NUMBER_IN_CLUSTER];
messageIdList = new MessageIdList[NUMBER_IN_CLUSTER];
ActiveMQDestination destination = createDestination();
for (int i = 0; i < NUMBER_IN_CLUSTER; i++) {
connections[i] = createConnection(i);
connections[i].setClientID("ClusterTest" + i);
connections[i].start();
Session session = connections[i].createSession(false, Session.AUTO_ACKNOWLEDGE);
producers[i] = session.createProducer(destination);
producers[i].setDeliveryMode(deliveryMode);
MessageConsumer consumer = createMessageConsumer(session, destination);
messageIdList[i] = new MessageIdList();
consumer.setMessageListener(messageIdList[i]);
}
LOG.info("Waiting for cluster to be fully connected");
// Each connection should see that NUMBER_IN_CLUSTER consumers get
// registered on the destination.
ActiveMQDestination advisoryDest = AdvisorySupport.getConsumerAdvisoryTopic(destination);
for (int i = 0; i < NUMBER_IN_CLUSTER; i++) {
Session session = connections[i].createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageConsumer consumer = createMessageConsumer(session, advisoryDest);
int j = 0;
while (j < NUMBER_IN_CLUSTER) {
ActiveMQMessage message = (ActiveMQMessage) consumer.receive(1000);
if (message == null) {
fail("Connection " + i + " saw " + j + " consumers, expected: " + NUMBER_IN_CLUSTER);
}
if (message.getDataStructure() != null && message.getDataStructure().getDataStructureType() == ConsumerInfo.DATA_STRUCTURE_TYPE) {
j++;
}
}
session.close();
}
LOG.info("Cluster is online.");
}
use of org.apache.activemq.util.MessageIdList in project activemq-artemis by apache.
the class FanoutTest method assertMessagesReceived.
protected void assertMessagesReceived(String brokerURL) throws Exception {
ActiveMQConnectionFactory consumerFactory = new ActiveMQConnectionFactory(brokerURL);
Connection consumerConnection = consumerFactory.createConnection();
consumerConnection.start();
Session consumerSession = consumerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageConsumer consumer = consumerSession.createConsumer(consumerSession.createQueue("TEST"));
MessageIdList listener = new MessageIdList();
consumer.setMessageListener(listener);
listener.waitForMessagesToArrive(messageCount);
listener.assertMessagesReceived(messageCount);
consumer.close();
consumerSession.close();
consumerConnection.close();
}
Aggregations