postDeliver(sess, isConnectionConsumer, cancel);
if (!isConnectionConsumer) { sess.postDeliver(cancel); }
   public static void callOnMessage(SessionDelegate sess,                                    MessageListener listener,                                    int consumerID,                                    long channelID,                                    boolean isConnectionConsumer,                                    MessageProxy m,                                    int ackMode,                                    int maxDeliveries)      throws JMSException   {      preDeliver(sess, consumerID, channelID, m, isConnectionConsumer);                        int tries = 0;            boolean cancel = false;            while (true)      {         try         {            if (trace) { log.trace("calling listener's onMessage(" + m + ")"); }                        m.incDeliveryCount();                        listener.onMessage(m);            if (trace) { log.trace("listener's onMessage() finished"); }                        break;         }         catch (RuntimeException e)         {            long id = m.getMessage().getMessageID();               log.error("RuntimeException was thrown from onMessage, " + id + " will be redelivered", e);                        // See JMS 1.1 spec 4.5.2               if (ackMode == Session.AUTO_ACKNOWLEDGE || ackMode == Session.DUPS_OK_ACKNOWLEDGE)            {               // We redeliver a certain number of times               if (tries < maxDeliveries)               {                                              tries++;               }               else               {                  log.error("Max redeliveries has occurred for message: " + m.getJMSMessageID());                                    // postdeliver will do a cancel rather than an ack which will cause the mesage                  // to end up in the DLQ                                    cancel = true;                                    break;               }            }            else            {               // Session is either transacted or CLIENT_ACKNOWLEDGE               // We just deliver next message               if (trace) { log.trace("ignoring exception on " + id); }                              break;            }         }      }      if (!sess.isClosed())      {         // postDeliver only if the session is not closed         postDeliver(sess, isConnectionConsumer, cancel);      }   }