[rabbitmq-discuss] To know when a queue is empty from a Java client
Simon MacMullen
simon at rabbitmq.com
Thu Aug 26 15:13:15 BST 2010
On 26/08/10 15:05, Florence Chabanois wrote:
> 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();
That's declaring a *new* server-named queue - which has 0 messages in
it. Is that literally your code, or a paraphrase?
Cheers, Simon
> 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
>
>
>
>
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-discuss at lists.rabbitmq.com
> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
--
Simon MacMullen
Staff Engineer, RabbitMQ
SpringSource, a division of VMware
More information about the rabbitmq-discuss
mailing list