Connection connection = createConnection();
Session session = connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
Queue queue = session.createQueue(name.toString());
sendMessages(connection, queue, msgCount);
QueueViewMBean queueView = getProxyToQueue(name.toString());
LOG.info("Queue size after produce is: {}", queueView.getQueueSize());
assertEquals(msgCount, queueView.getQueueSize());
// Consumer all in TX and commit.
{
MessageConsumer consumer = session.createConsumer(queue);
for (int i = 0; i < msgCount; ++i) {
if ((i % 100) == 0) {
LOG.info("Attempting receive of Message #{}", i);
}
Message msg = consumer.receive(TestConfig.TIMEOUT);
assertNotNull("Should receive message: " + i, msg);
assertTrue(msg instanceof TextMessage);
}
session.commit();
consumer.close();
session.close();
}
connection.close();
LOG.info("Queue size after produce is: {}", queueView.getQueueSize());
assertEquals(0, queueView.getQueueSize());
}