boolean handled = buffer.offer(processMessage(md), 500);
boolean handled = buffer.offer(processMessage(md), 10000);
   public synchronized void handleMessage(MessageProxy md) throws HandleCallbackException   {      if (trace) { log.trace("receiving message " + md + " from the remoting layer"); }      if (closed)      {         log.warn("Consumer is closed - ignoring message");         // Note - we do not cancel the message if the handler is closed. If the handler is closed         // then the corresponding server consumer endpoint is either already closed or about to         // close, in which case its deliveries will be cancelled anyway.         return;      }            if (listener != null)      {         //Queue the message to be delivered by the session         ClientDeliveryRunnable cdr = new ClientDeliveryRunnable(this, processMessage(md));         try         {            onMessageExecutor.execute(cdr);         }         catch (InterruptedException e)         {            log.error("Thread was interrupted, cancelling message", e);            cancelMessage(md);         }      }      else      {                                          try         {                                //We attempt to put the message in the Channel            //The call will return false if the message is not picked up the receiving            //thread in which case we need to cancel it                        //channel.offer will *only* return true if there is a thread waiting to take a            //message using take() or poll() hence we can guarantee there is no chance any            //messages can arrive and are left in the channel without being handled -  this is            //why we use a SynchronousChannel :)                        //We do this in a while loop to deal with a possible race condition where            //waiting had been set but the main consumer thread hadn't quite blocked on the call            //to take or poll from the channel                        boolean handled = buffer.offer(processMessage(md), 500);                                                         if (!handled)            {               //There is no-one waiting for our message so we cancel it               if (!closed)               {                  cancelMessage(md);               }            }                       }         catch(InterruptedException e)         {            String msg = "Interrupted attempt to put message in the delivery buffer";            log.error(msg);            throw new HandleCallbackException(msg, e);         }      }         }