catch (JMSException e) { log.error("Failed to cancel message " + m, e);  if (log.isTraceEnabled()) { log.trace("returning"); } return; }  try { JBossMessage jm = (JBossMessage)m;    if (!this.isConnectionConsumer) { jm.setSessionDelegate(sessionDelegate); } if (log.isTraceEnabled()) { log.trace("trying to put " + m + " in the client delivery queue"); } messages.put(m); if (log.isTraceEnabled()) { log.trace(m + " was successfully queued in the client delivery queue, thread exiting"); } } catch(InterruptedException e) { String msg = "Interrupted attempt to put message in the delivery buffer"; log.warn(msg); throw new HandleCallbackException(msg, e); }
   public void handleCallback(Callback callback) throws HandleCallbackException   {      if (log.isTraceEnabled()) { log.trace("receiving message " + callback.getParameter() + " from the remoting layer"); }      Message m = (Message)callback.getParameter();      try      {         boolean cancel = false;         if (!isListening() && !isReceiving())         {            //There is a small chance, but possible that a receive times out or a message listener            //is unset before then later it receives a message            //this message cannot be handled so it needs to be sent back            //to the server to be cancelled            if (log.isTraceEnabled()) { log.trace("NOT listening and NOT receiving"); }            cancel = true;         }         else if (isClosed())         {            log.warn("Tried to deliver message but consumer is closed!!");            cancel = true;         }         if (cancel)         {            if (log.isTraceEnabled()) { log.trace("cancelling message " + m.getJMSMessageID()); }            consumerDelegate.cancelMessage(m.getJMSMessageID());            if (log.isTraceEnabled()) { log.trace("message " + m.getJMSMessageID() + " cancelled, returning"); }            return;         }      }      catch (JMSException e)      {         log.error("Failed to cancel message " + m, e);         //TODO - if I don't return, the message I wanted to cancel goes to buffer. Do I want that?         if (log.isTraceEnabled()) { log.trace("returning"); }         return;      }        try      {			         JBossMessage jm = (JBossMessage)m;	         //if this is the handler for a connection consumer we don't want to set the session delegate         //since this is only used for client acknowledgement which is illegal for a session         //used for an MDB         if (!this.isConnectionConsumer)         {            jm.setSessionDelegate(sessionDelegate);         }         if (log.isTraceEnabled()) { log.trace("trying to put " + m + " in the client delivery queue"); }         messages.put(m);         if (log.isTraceEnabled()) { log.trace(m + " was successfully queued in the client delivery queue, thread exiting"); }      }      catch(InterruptedException e)      {         String msg = "Interrupted attempt to put message in the delivery buffer";         log.warn(msg);         throw new HandleCallbackException(msg, e);      }   }