if (log.isTraceEnabled()) { log.trace(this + " DOES NOT accept the message"); }
if (trace) { log.trace(this + " DOES NOT accept the message"); }
   public Delivery handle(DeliveryObserver observer, Routable reference, Transaction tx)   {      if (log.isTraceEnabled()) { log.trace(this + " receives reference " + Util.guidToString(reference.getMessageID()) + " for delivery"); }      if (!isReady())      {         if (log.isTraceEnabled()) { log.trace(this + " rejects " + Util.guidToString(reference.getMessageID())); }         return null;      }            try      {         Delivery delivery = null;                  JBossMessage message = (JBossMessage)reference.getMessage();                  boolean accept = this.accept(message);         if (!accept)         {            if (log.isTraceEnabled()) { log.trace(this + " DOES NOT accept the message"); }            return null;         }                  //TODO - We need to put the message in a DLQ         //For now we just ack it otherwise the message will keep being retried         //and we'll never get anywhere         if (reference.getDeliveryCount() > MAX_DELIVERY_ATTEMPTS)         {            log.warn("Message has exceed maximum delivery attempts and will be removed " + message);            delivery = new SimpleDelivery(observer, (MessageReference)reference, true);            return delivery;         }                                           delivery = new SimpleDelivery(observer, (MessageReference)reference);                           deliveries.put(reference.getMessageID(), delivery);                           //We don't send the message as-is, instead we create a MessageDelegate instance         //This allows local fields such as deliveryCount to be handled by the delegate         //but global data to be fielded by the same underlying Message instance.         //This allows us to avoid expensive copying of messages         MessageDelegate md = JBossMessage.createThinDelegate(message, reference.getDeliveryCount());                  if (!grabbing)         {            //We want to asynchronously deliver the message to the consumer            //deliver the message on a different thread than the core thread that brought it here                        try            {               if (log.isTraceEnabled()) { log.trace("queueing message " + message + " for delivery to client"); }                              threadPoolDelegate.execute(new DeliveryRunnable(callbackHandler, md));            }            catch (InterruptedException e)            {               log.warn("Thread interrupted", e);            }         }         else         {            //The message is being "grabbed" and returned for receiveNoWait semantics            toGrab = md;         }                  return delivery;           }      finally      {         active = false;         grabbing = false;      }   }