You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by rolandpeng <ro...@cht.com.tw> on 2012/09/13 17:31:26 UTC
consumer.receiveNoWait() question
There are some pending messages in my queue.
I call consumer.receiveNoWait(), but the consumer returns null.
Is it possible to receive pending messages by calling receiveNoWait()?
Any comment will be grateful , thank you.
--
View this message in context: http://activemq.2283324.n4.nabble.com/consumer-receiveNoWait-question-tp4656435.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Re: consumer.receiveNoWait() question
Posted by rolandpeng <ro...@cht.com.tw>.
thank you tabish!
You've mentioned the key point.
For some reason I have to set the prefetch size=0 in my connection
string(jms.prefetchPolicy.queuePrefetch=0).
That's no wonder why I always receive null message while I call
receveNoWait().
I will call receive(timeout) instead. thanks again!
--
View this message in context: http://activemq.2283324.n4.nabble.com/consumer-receiveNoWait-question-tp4656435p4656616.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Re: consumer.receiveNoWait() question
Posted by Timothy Bish <ta...@gmail.com>.
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 <ro...@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.bish@fusesource.com
Web: http://fusesource.com
Twitter: tabish121
Blog: http://timbish.blogspot.com
Re: consumer.receiveNoWait() question
Posted by rolandpeng <ro...@cht.com.tw>.
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.
Re: consumer.receiveNoWait() question
Posted by prabugp <pr...@gmail.com>.
receiveNoWait() should retrieve the message, if there is one available in the
queue to be picked up. I'd check the configuration of the consumer to see if
it's listening on the Queue of interest and also that there are no message
selectors involved that could make the consumer not pick the msg. This
doesn't look like it has anything to do with ActiveMQ ( at least from what
is said in the description).
--
View this message in context: http://activemq.2283324.n4.nabble.com/consumer-receiveNoWait-question-tp4656435p4656609.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.