executor.execute(new Runner(callback));
callbackHandler.handleCallback(callback);
   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 (!clientAccepting)      {         if (trace) { log.trace(this + " the client is not currently accepting messages"); }                  return null;      }              synchronized (startStopLock)      {                  // If the consumer is stopped then we don't accept the message, it should go back into the         // queue for delivery later.         if (!started)         {            if (trace) { log.trace(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;         }                          if (delivery.isDone())         {            return delivery;         }                  long deliveryId = sessionEndpoint.addDelivery(delivery, id);            // 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(deliveryId, message, ref.getDeliveryCount());             //We send the message to the client on the current thread.         //The message is written onto the transport and then the thread returns immediately         //without waiting for a response                  //FIXME - how can we ensure that a later send doesn't overtake an earlier send - this might         //happen if they are using different underlying TCP connections (e.g. from pool)                  ClientDelivery del = new ClientDelivery(mp, id);                  MessagingMarshallable mm = new MessagingMarshallable(versionToUse, del);                  Callback callback = new Callback(mm);            //FIXME - we need to use the asynch callback API, this is the Sync one         //This is temporary - to ensure deliveries happen in sequence!!!!!!!!                  class Runner implements Runnable         {            Callback cb;                        Runner(Callback cb)            {               this.cb = cb;            }                     public void run()            {               try               {                              callbackHandler.handleCallback(cb);                              }               catch (HandleCallbackException e)               {                  log.error("Failed to handle callback", e);               }                           }           }                  try         {            executor.execute(new Runner(callback));         }         catch (InterruptedException e)         {            //Ignore         }                    return delivery;            }   }      