if (message.getDeliveryCount() > MAX_DELIVERY_ATTEMPTS)
if (reference.getDeliveryCount() > MAX_DELIVERY_ATTEMPTS)
   public synchronized Delivery handle(DeliveryObserver observer, Routable reference, Transaction tx)   {      if (log.isTraceEnabled()) { log.trace("Attempting to handle ref: " + reference.getMessageID()); }            if (!wantReference())      {         return null;      }            try      {                  if (log.isTraceEnabled()) { log.trace("Delivering ref " + reference.getMessageID()); }                  Delivery delivery = null;         Message message = reference.getMessage();                  boolean accept = this.accept(message);         if (!accept)         {            if (log.isTraceEnabled()) { log.trace("consumer DOES NOT accept the message"); }            return null;         }                  //TODO This should really go in core         message.incrementDeliveryCount();                           //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 (message.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.add(delivery);                  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"); }               threadPool.execute(new DeliveryRunnable(callbackHandler, message));            }            catch (InterruptedException e)            {               log.warn("Thread interrupted", e);            }         }         else         {            //The message is being "grabbed" and returned for receiveNoWait semantics            toGrab = message;         }                  return delivery;           }      finally      {         ready = false;         grabbing = false;      }   }