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

Florence Chabanois flocha2000-agile at yahoo.fr
Thu Aug 26 15:05:59 BST 2010


Thanks for your answer !
We may be using it in a wrong way but so far, the method getMessageCount() always displays 0 message, when "rabbitmqctl list_queues" displays 8 messages or keeps growing.
DeclareOk declareOk = channel.queueDeclare();System.out.println(">>>> MESSAGES : " + declareOk.getMessageCount());
Cheers,Florence.

--- En date de : Jeu 26.8.10, Michael Bridgen <mikeb at rabbitmq.com> a écrit :

De: Michael Bridgen <mikeb at rabbitmq.com>
Objet: Re: [rabbitmq-discuss] To know when a queue is empty from a Java client
À: flocha2000-agile at yahoo.fr
Cc: rabbitmq-discuss at lists.rabbitmq.com
Date: Jeudi 26 août 2010, 15h24

>  From a Java client we need to know when a queue is empty.
> Is there a way to know it via the Java api (or to know the number
> of messages in a queue).
> 
> We would rather have another way than calling /"rabbitmqctl list_queues"/
> via Runtime.exec()

A queue.declare_ok frame includes the number of messages on the queue; so, you could send a passive queue.declare, and examine the response.

Regards,
Michael



      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20100826/2bc93f42/attachment.htm>


More information about the rabbitmq-discuss mailing list