if (connection == null) {
connection = createConnection();
}
connection.start();
ConsumerBean messageList = new ConsumerBean();
messageList.setVerbose(true);
ActiveMQDestination consumeDestination = createConsumeDestination();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
LOG.info("Consuming from: " + consumeDestination);
MessageConsumer c1 = session.createConsumer(consumeDestination);
c1.setMessageListener(messageList);
// create topic producer
ActiveMQQueue sendDestination = new ActiveMQQueue(getQueueName());
LOG.info("Sending to: " + sendDestination);
MessageProducer producer = session.createProducer(sendDestination);
assertNotNull(producer);
final int total = 10;
for (int i = 0; i < total; i++) {
producer.send(session.createTextMessage("message: " + i));
}
messageList.assertMessagesArrived(total);
LOG.info("Received: " + messageList);
messageList.flushMessages();
MessageConsumer c2 = session.createConsumer(sendDestination);
c2.setMessageListener(messageList);
messageList.assertMessagesArrived(total);
LOG.info("Q Received: " + messageList);
connection.close();
List<ObjectName> topics = Arrays.asList(broker.getAdminView().getTopics());