ref.releaseMemoryReference();
   public Delivery handle(DeliveryObserver sender, Routable r, Transaction tx)   {                  checkClosed();            if (r == null)      {         return null;      }      if (trace){ log.trace(this + " handles " + r + (tx == null ? " non-transactionally" : " in transaction: " + tx) ); }      MessageReference ref = obtainReference(r);            try      {                  if (tx == null)         {            // Don't even attempt synchronous delivery for a reliable message when we have an            // non-recoverable state that doesn't accept reliable messages. If we do, we may get            // into the situation where we need to reliably store an active delivery of a reliable            // message, which in these conditions cannot be done.            if (r.isReliable() && !state.acceptReliableMessages())            {               log.error("Cannot handle reliable message " + r +                         " because the channel has a non-recoverable state!");               return null;            }            // This returns true if the ref was added to an empty reference queue            boolean first = state.addReference(ref);                        // Previously we would call push() at this point to push the reference to the consumer.            // One of the problems this had was it would end up leap-frogging messages that were            // already in the queue. So now we add the message to the back of the queue and call            // deliver(). In fact we only need to call deliver() if the queue was empty before we            // added the reference.            // If the queue wasn't empty there would be no active waiting receiver, so there would            // be no need to call deliver().                        if (first)            {               deliver(this, null);                     }         }         else         {               if (trace){ log.trace("adding " + ref + " to state " + (tx == null ? "non-transactionally" : "in transaction: " + tx) ); }                        state.addReference(ref, tx);                  }      }      catch (Throwable t)      {         log.error("Failed to handle message", t);                  return null;      }      // I might as well return null, the sender shouldn't care      return new SimpleDelivery(sender, ref, true);   }