0

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

1 Answer 1

1

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;

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, but I need to do it from a java application, not by console (and by console it seems to be a slow query).
The messageCount method doesn't work for me, it always returns 0 messages. For more information, I am using the Spring-amqp framework.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.