[rabbitmq-discuss] To know when a queue is empty from a Java client

Mark Pollack mpollack at vmware.com
Thu Aug 26 16:58:16 BST 2010


The Spring AMQP project provides some initial support for an admin API.  We use JInterface to call the erlang functions used by rabbitmqctl.

Take a look at the javadocs here


We are not yet complete in supporting the full range of functionality available in rabbitmqctl but that is the goal.

There is also a .NET version.


From: rabbitmq-discuss-bounces at lists.rabbitmq.com [mailto:rabbitmq-discuss-bounces at lists.rabbitmq.com] On Behalf Of Jon Brisbin
Sent: Thursday, August 26, 2010 10:41 AM
To: flocha2000-agile at yahoo.fr
Cc: RabbitMQ
Subject: Re: [rabbitmq-discuss] To know when a queue is empty from a Java client

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?


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/957ae4b7/attachment-0001.htm>

More information about the rabbitmq-discuss mailing list