public void testAckedMessageAreConsumed() throws Exception {
  connection.start();
  Session session=connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
  Queue queue=session.createQueue("test");
  MessageProducer producer=session.createProducer(queue);
  producer.send(session.createTextMessage("Hello"));
  MessageConsumer consumer=session.createConsumer(queue);
  consumer.setMessageListener(this);
  Thread.sleep(10000);
  session=connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
  consumer=session.createConsumer(queue);
  Message msg=consumer.receive(1000);
  assertNull(msg);
  session.close();
}

public void testAckedMessageAreConsumed ( ) throws Exception { connection . start ( ) ; Session session = connection . createSession ( false , Session . AUTO_ACKNOWLEDGE ) ; Queue queue = session . createQueue ( "test" ) ; MessageProducer producer = session . createProducer ( queue ) ; producer . send ( session . createTextMessage ( "Hello" ) ) ; MessageConsumer consumer = session . createConsumer ( queue ) ; consumer . setMessageListener ( this ) ; Thread . sleep ( 10000 ) ; session = connection . createSession ( false , Session . AUTO_ACKNOWLEDGE ) ; consumer = session . createConsumer ( queue ) ; Message msg = consumer . receive ( 1000 ) ; assertNull ( msg ) ; session . close ( ) ; }
tests if acknowledged messages are being consumed .
