jandres
jandres

Reputation: 479

RabbitMQ and queue data

I have an application with RabbitMQ where I get the number of messages in a Rabbit queue using the HTTP API (/api/queues/vhost/name). However, it appears that this information is refreshed from time to time (by default every 5 seconds). I thought the information was always up to date, and it was the administration page that was updated in a given interval.

Is there any way to get the number of messages in a queue with real-time information?

Thank you

Upvotes: 0

Views: 398

Answers (1)

Gabriele Santomaggio
Gabriele Santomaggio

Reputation: 22750

The management database is updated each 5 seconds by default.

use the command line rabbitmqctl list_queues for real-time values.

Try to use:

channel.messageCount(you_queue)

see if it works for you

/** * Returns the number of messages in a queue ready to be delivered * to consumers. This method assumes the queue exists. If it doesn't, * an exception will be closed with an exception. * @param queue the name of the queue * @return the number of messages in ready state * @throws IOException Problem transmitting method. */ long messageCount(String queue) throws IOException;

Upvotes: 1

Related Questions