[rabbitmq-discuss] To know when a queue is empty from a Java client
Jon Brisbin
jon.brisbin at npcinternational.com
Thu Aug 26 15:41:12 BST 2010
On Aug 26, 2010, at 9:34 AM, Florence Chabanois wrote:
>
> Hum indeed, this is literally our code...
>
> So if declare_ok always refers to a new queue, we have no choice but use Runtime.exec("rabbitmqctl list_queues") if we want to know this kind of information on an existing queue?
>
> Cheers,
> Florence.
>
Actually, your code is creating a new queue, so in your example, the declare_ok will always refer to a new queue.
But if you declare a queue that already exists (which a producer has already populated with messages), you'll get back the message count. Give a name to your queue and have the producer and consumer use the same name.
If you attach your consumer to a new queue (which you're doing by creating an anonymous queue) the message count will obviously be zero because nothing has put messages in it yet.
Jon Brisbin
Portal Webmaster
NPC International, Inc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20100826/8d45d57b/attachment.htm>
More information about the rabbitmq-discuss
mailing list