Uploaded image for project: 'HornetQ'
  1. HornetQ
  2. HORNETQ-858

Change system time to past time point will cause org.hornetq.core.client.impl.ClientConsumerImpl.receive(long) API can not return

    Details

      Description

      Case:
      I have a thread to poll event from HornetQ in period with javax.jms.MessageConsumer.receive(long) API. The timeout value is 30 seconds. If I change system to past time point like from 2011.11.10 to 2011.11.09. I found the API will have problem and can not return after 30 seconds

      Analysis:
      I check the API and found the issue is caused by org.hornetq.core.client.impl.ClientConsumerImpl.receive(long, boolean) API. Following is the code with my analysis. toWait can be big negative number in this case. can we add a check to make this case work?

      while ((stopped || (m = buffer.poll()) == null) && !closed && toWait > 0)

      {

      if (start == -1)

      { start = System.currentTimeMillis(); //record start time }

      if (m == null && forcingDelivery)

      {

      if (stopped)

      { break; }

      // we only force delivery once per call to receive

      if (!deliveryForced)

      {

      if (isTrace)

      { log.trace("Forcing delivery"); }

      session.forceDelivery(id, forceDeliveryCount++);

      deliveryForced = true;

      }

      }

      try

      { wait(toWait); }

      catch (InterruptedException e)

      {

      }

      if (m != null || closed)

      { break; }

      long now = System.currentTimeMillis();

      //record the time now. If we change system time from a future time to now, the now - start will be big negative time.

      toWait -= now - start;

      start = now;

      }

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                clebert.suconic Clebert Suconic
                Reporter:
                dengyong Yong Deng
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated: