final int NUM_MESSAGES = 10;
//Send some messages
for (int i = 0; i < NUM_MESSAGES; i++)
{
Message m = producerSess.createMessage();
producer.send(m);
}
log.trace("Sent messages");
int count = 0;
while (true)
{
Message m = consumer.receive(500);
if (m == null) break;
count++;
}
log.trace("Received " + count + " messages");
assertEquals(NUM_MESSAGES, count);
consumerSess.commit();
log.trace("Committed session");
conn.stop();
consumer.close();
conn.close();
conn = cf.createConnection();
consumerSess = conn.createSession(true, Session.CLIENT_ACKNOWLEDGE);
consumer = consumerSess.createConsumer(queue);
conn.start();
Message m = consumer.receive(2000);
log.trace("Message is " + m);
assertNull(m);
}