sessCons.setMessageListener(listener);
ServerSessionPool pool = new MockServerSessionPool(sessCons);
JBossConnectionConsumer cc = (JBossConnectionConsumer)connConsumer.createConnectionConsumer(queue, null, pool, 1);
connProducer = cf.createConnection();
Session sessProd = connProducer.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer prod = sessProd.createProducer(queue);
for (int i = 0; i < NUM_MESSAGES; i++)
{
TextMessage m = sessProd.createTextMessage("testing testing");
prod.send(m);
}
//Wait for messages
listener.waitForLatch(10000);
if (listener.getMsgsReceived() != NUM_MESSAGES)
{
fail("Didn't receive all messages");
}
if (listener.failed)
{
fail ("Didn't receive correct messages");
}
log.trace("Received all messages");
log.trace("closing connection consumer ...");
cc.close();
log.trace("closing connections ...");
connProducer.close();
connProducer = null;