if (log.isTraceEnabled()) { log.trace("It's closed"); }
   public Message receive(long timeout, JMSMethodInvocation jmsmi, Interceptor receiverInt)      throws JMSException, InterruptedException   {                  //Since the jms consumer is single threaded,      //it shouldn't be possible for a receive to be called when another receive is in operation      //or while a close is in operation.      //But it is possible for a receive to be called while a message listener is set            if (listening)      {         throw new JBossJMSException("A message listener is already registered");               }            receiving = true;            receiverThread = Thread.currentThread();            long startTimestamp = System.currentTimeMillis();            JBossMessage m = null;            try      {         while(true)         {            try            {               if (timeout == 0)               {                  if (log.isTraceEnabled()) log.trace("receive with no timeout");                                    if (!receiverStopping)                  {                     m = getMessage(0);                  }                                    if (m == null)                  {                     return null;                  }                                    if (log.isTraceEnabled()) { log.trace("Got message: " + m); }               }               else if (timeout == -1)               {                  //ReceiveNoWait                  if (log.isTraceEnabled()) { log.trace("receive noWait"); }                                                      if (!receiverStopping)                  {                     m = getMessage(-1);                  }                                    if (m == null)                  {                     if (log.isTraceEnabled()) { log.trace("No message available"); }                     return null;                  }               }               else               {                  if (log.isTraceEnabled()) { log.trace("receive timeout " + timeout + " ms, blocking poll on queue"); }                                    if (!receiverStopping)                  {                     m = getMessage(timeout);                  }                                    if (m == null)                  {                     // timeout expired                     if (log.isTraceEnabled()) { log.trace(timeout + " ms timeout expired"); }                                          return null;                  }               }            }            catch(InterruptedException e)            {               if (log.isTraceEnabled()) { log.trace("Thread was interrupted"); }                              if (closed)               {                  if (log.isTraceEnabled()) { log.trace("It's closed"); }                  return null;               }               else               {                  throw e;               }                      }                        if (log.isTraceEnabled()) { log.trace("got " + m); }                                           if (!m.isExpired())            {               if (log.isTraceEnabled()) { log.trace("message " + m + " is not expired, returning it to the caller"); }               preDeliver(m);               postDeliver(m);               return m;            }                        log.debug("message expired, discarding");                        // discard the message, adjust timeout and reenter the buffer            if (timeout != 0)            {               timeout -= System.currentTimeMillis() - startTimestamp;            }         }      }      finally      {         receiving = false;         receiverThread = null;      }    }