activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Timothy Bish <>
Subject Re: consumer.receiveNoWait() question
Date Wed, 19 Sep 2012 01:44:10 GMT
The contract of the receiveNoWait method is such that it never guarantees
that it will return a message.  In your case its most likely that the
Message that's pending in the Queue has not reached the client's prefetch
buffer.  Your code should take into account the fact that the receiveNoWait
method can return null and retry as needed.  Its likely that the message
will be returned on the next call but again it depends on how long it takes
for the broker to dispatch the messages to the client's prefetch buffer and
the speed of the network in between the two.

On Tue, Sep 18, 2012 at 9:25 PM, rolandpeng <> wrote:

> thank you prabugp.
> These are my codes listed below,
> myQueue = session.createQueue(queueName);
> myCons = session.createConsumer(myQueue);
> inMsg = myCons.receiveNoWait();
> so sure that I've listened to the right queue and no message selectors as
> well.
> When the program runs into myCons.receiveNoWait(), it still remains several
> pending messages in the queue.
> But inMsg was null as return.
> It seems not make sense that pending messages are not available.
> (receiveNoWait() should retrieve the message, if there is one available in
> the queue to be picked up.)
> --
> View this message in context:
> Sent from the ActiveMQ - User mailing list archive at

Tim Bish
RedHat Software
Twitter: tabish121

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message