log.info("Closed connection consumer");
log.trace("Closed connection consumer");
   public void testRedelivery() throws Exception   {      if (ServerManagement.isRemote()) return;            final int NUM_MESSAGES = 10;            Connection connConsumer = null;            Connection connProducer = null;            try      {         connConsumer = cf.createConnection();                          connConsumer.start();                           Session sessCons = connConsumer.createSession(true, Session.SESSION_TRANSACTED);                  SimpleMessageListener listener = new SimpleMessageListener(NUM_MESSAGES);                  sessCons.setMessageListener(listener);                  ServerSessionPool pool = new MockServerSessionPool(sessCons);                  JBossConnectionConsumer cc = (JBossConnectionConsumer)connConsumer.createConnectionConsumer(queue, null, pool, 1);                           log.trace("Started connection consumer");                  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);         }                  log.trace("Sent messages");                  //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");                           // Now rollback the session         // This is what the app server would do if an unchecked exception is thrown         // or the tx is marked for rollback                  //the messages should be redelivered since they have not been acked                          listener = new SimpleMessageListener(NUM_MESSAGES);         sessCons.setMessageListener(listener);                   log.info("Rolling back session");         sessCons.rollback();              listener.waitForLatch(10000);                  log.trace("Messages received in recovery:" + listener.getMsgsReceived());                  if (listener.getMsgsReceived() != NUM_MESSAGES)         {            fail("Didn't receive all messages in redelivery");         }                  if (listener.failed)         {            fail ("Didn't receive correct messages in redelivery");         }                  log.info("Received all messages in redelivery");                  sessCons.commit();                  log.info("Committed session");                  cc.close();                  log.info("Closed connection consumer");                  connProducer.close();         connProducer = null;         connConsumer.close();         connConsumer = null;                   }      finally       {         if (connConsumer != null) connConsumer.close();         if (connConsumer != null) connProducer.close();      }   }