Uploaded image for project: 'Qpid'
  1. Qpid
  2. QPID-1642

JMS ReceiveNowait does not return a message even if the queue is not empty

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • M4
    • JIRA Cleanup
    • JMS AMQP 0-x
    • None

    Description

      Description:
      The first invocation of receiveNoWait does not return a message even if the queue is full.
      How to replicate:
      1) create a queue
      2) send a message
      3) try to consume this message using receiveNoWait
      ==> we get null even if there is a message seating in the queue
      Solution:
      When a JMS consumer first invokes receiveNowait then BasicMessageConsumer_0_10 request for more credits and then poll the _synchronousQueue. This does not leave enough time for the message to be enqueued.
      One solution would be to query the queue size before allowing the credits: Something like that would work:
      public Object getMessageFromQueue(long l) throws InterruptedException
      {
      long size = 0;
      if(l < 0)

      { size = _0_10session.requestQueueDepth(getDestination()) ; }

      if (isStrated() && ! getSession().prefetch() && _synchronousQueue.isEmpty())

      { _0_10session.getQpidSession().messageFlow(getConsumerTagString(), MessageCreditUnit.MESSAGE, 1); }

      if (! getSession().prefetch())

      { _syncReceive.set(true); }

      Object o;// = super.getMessageFromQueue(l);
      if (l > 0)

      { o = _synchronousQueue.poll(l, TimeUnit.MILLISECONDS); }

      else if (l < 0)
      {
      if(size <= 0 )

      { o = _synchronousQueue.poll(); }

      else

      { o = _synchronousQueue.take(); }

      }
      else

      { o = _synchronousQueue.take(); }

      if (! getSession().prefetch())

      { _syncReceive.set(false); }

      return o;
      }

      Attachments

        Activity

          People

            Unassigned Unassigned
            arnaudsimon Arnaud Simon
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: