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 <rolandp...@cht.com.tw> 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:
> http://activemq.2283324.n4.nabble.com/consumer-receiveNoWait-question-tp4656435p4656614.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>



-- 
--
Tim Bish
-------------------
RedHat Software
Email: tim.b...@fusesource.com
Web: http://fusesource.com
Twitter: tabish121
Blog: http://timbish.blogspot.com

Reply via email to