You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Christian Posta <ch...@gmail.com> on 2013/01/30 16:50:34 UTC

Re: AMQ issues with consumer.receive vs consumer.receiveNoWait

what are you using for prefetch?
if you're using receiveNoWait() there is definitely a window where the
broker is still delivering to the session's prefetch. if you happen to call
receiveNoWait when the session still hasn't seen the message, then the
consumer will return null. this is one of those things you kinda have to
code for when you use receiveNoWait. even though the broker has messages in
the queue, there's no guarantee when the message made it to the consumer's
session. on the other hand, if you set prefetch to 0, then the consumer
will actively poll the broker for a message. this can be a little
inefficient if you have fast consumers though. otherwise, receive(tmeout)
is your best bet.

cheers


On Wed, Jan 30, 2013 at 8:03 AM, Oleg Dulin <ol...@gmail.com> wrote:

> Dear Distinguished Colleagues:
>
> I am having a strange problem where I know my queue has pending messages
> on it that should be immediatley available to a consumer.receiveNoWait call.
>
> However, more often than not those calls return null.
>
> On the other hand, calling receive with a small timeout seems to work.
>
> Any thoughts and suggestions are greatly appreciated.
>
>
> --
> Regards,
> Oleg Dulin
> NYC Java Big Data Engineer
> http://www.olegdulin.com/
>
>
>


-- 
*Christian Posta*
http://www.christianposta.com/blog
twitter: @christianposta