log.info(this + " remnoving all references");
   public void removeAllReferences() throws Throwable   {      synchronized (refLock)      {         synchronized (deliveryLock)         {            //Ack the deliveries            //Clone to avoid ConcurrentModificationException            Set dels = new HashSet(deliveries);            Iterator iter = dels.iterator();            while (iter.hasNext())            {               SimpleDelivery d = (SimpleDelivery) iter.next();               d.acknowledge(null);            }            //Now we consume the rest of the messages            //This may take a while if we have a lot of messages including perhaps millions            //paged in the database - but there's no obvious other way to do it.            //We cannot just delete them directly from the database - because we may end up with messages leaking            //in the message store,            //also we might get race conditions when other channels are updating the same message in the db            //Note - we don't do this in a tx - because the tx could be too big if we have millions of refs            //paged in storage            MessageReference ref;            while ((ref = removeFirstInMemory()) != null)            {               SimpleDelivery del = new SimpleDelivery(this, ref, false);               del.acknowledge(null);            }         }      }   }