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(); consumerConnection.close(); consumerSession.close();
}
}