log.info(this + " receives " + ref + " for delivery");
   public Delivery handle(DeliveryObserver observer, MessageReference ref, Transaction tx)   {      if (trace) { log.trace(this + " receives " + ref + " for delivery"); }            // This is ok to have outside lock - is volatile      if (bufferFull)      {         // We buffer a maximum of PREFETCH_LIMIT messages at once                  if (trace) { log.trace(this + " has reached prefetch size will not accept any more references"); }                  return null;      }             // Need to synchronized around the whole block to prevent setting started = false      // but handle is already running and a message is deposited during the stop procedure.      synchronized (lock)      {           // If the consumer is stopped then we don't accept the message, it should go back into the         // queue for delivery later.         if (!started)         {            // this is a common programming error, make this visible in the debug logs. However,            // make also possible to cut out the performance overhead for systems that raise the            // threshold to INFO or higher.            if (log.isDebugEnabled())            {               log.debug(this + " NOT started yet!");            }            return null;         }         if (trace) { log.trace(this + " has the main lock, preparing the message for delivery"); }         JBossMessage message = (JBossMessage)ref.getMessage();                  boolean selectorRejected = !this.accept(message);            SimpleDelivery delivery = new SimpleDelivery(observer, ref, false, !selectorRejected);                  if (selectorRejected)         {            return delivery;         }                     checkDeliveryCount(delivery);                  if (delivery.isDone())         {            return delivery;         }            deliveries.put(new Long(ref.getMessageID()), delivery);                             // We don't send the message as-is, instead we create a MessageProxy instance. This allows         // local fields such as deliveryCount to be handled by the proxy but global data to be         // fielded by the same underlying Message instance. This allows us to avoid expensive         // copying of messages            MessageProxy mp = JBossMessage.createThinDelegate(message, ref.getDeliveryCount());             // Add the proxy to the list to deliver                                    toDeliver.add(mp);                        bufferFull = toDeliver.size() >= prefetchSize;                      if (!clientConsumerFull)         {                        try            {               if (trace) { log.trace(this + " scheduling a new Deliverer"); }               this.executor.execute(new Deliverer());            }            catch (InterruptedException e)            {               log.warn("Thread interrupted", e);            }         }                                      return delivery;                    }   }      