public void testUnAckedMessageAreNotConsumedOnSessionClose() throws Exception {
  connection.start();
  dontAck=true;
  Session session=connection.createSession(false,Session.CLIENT_ACKNOWLEDGE);
  Queue queue=session.createQueue("test");
  MessageProducer producer=session.createProducer(queue);
  producer.send(session.createTextMessage("Hello"));
  MessageConsumer consumer=session.createConsumer(queue);
  consumer.setMessageListener(this);
  session.close();
  Thread.sleep(10000);
  session=connection.createSession(false,Session.CLIENT_ACKNOWLEDGE);
  consumer=session.createConsumer(queue);
  Message msg=consumer.receive(2000);
  assertNotNull(msg);
  msg.acknowledge();
  session.close();
}

public void testUnAckedMessageAreNotConsumedOnSessionClose ( ) throws Exception { connection . start ( ) ; dontAck = true ; Session session = connection . createSession ( false , Session . CLIENT_ACKNOWLEDGE ) ; Queue queue = session . createQueue ( "test" ) ; MessageProducer producer = session . createProducer ( queue ) ; producer . send ( session . createTextMessage ( "Hello" ) ) ; MessageConsumer consumer = session . createConsumer ( queue ) ; consumer . setMessageListener ( this ) ; session . close ( ) ; Thread . sleep ( 10000 ) ; session = connection . createSession ( false , Session . CLIENT_ACKNOWLEDGE ) ; consumer = session . createConsumer ( queue ) ; Message msg = consumer . receive ( 2000 ) ; assertNotNull ( msg ) ; msg . acknowledge ( ) ; session . close ( ) ; }
tests if unacknowledged messages are being redelivered when the consumer connects again .
