Check RabbitMQ queue size (message count) from a client
Codemia Knowledge Hub ·
From client code, declare the queue in passive mode and read the message count from the reply. Outside your application, rabbitmqctl list_queues name messages or the management plugin's web UI and HTTP API give the same number.
Which queue metrics RabbitMQ reports
- Queue size (message count): Total number of messages currently in the queue.
- Ready messages: Messages ready to be delivered to consumers.
- Unacknowledged messages: Messages delivered to a consumer but not yet acknowledged.
Passive queue_declare in a client library
Most languages have a RabbitMQ client library (for example pika for Python or rabbitmq-c for C). With Pika:
The script connects to RabbitMQ, declares the queue in passive mode (so it is not created if it does not exist) and prints the number of messages.
rabbitmqctl on the command line
RabbitMQ ships with rabbitmqctl, which inspects the server state, including queue sizes:
This lists each queue with its message count.
Management plugin: web UI and HTTP API
The management plugin adds a web UI and an HTTP API for monitoring and managing RabbitMQ. Once it is enabled, the web interface is usually at http://<host>:15672/ and shows every queue with its metrics.
To fetch the data programmatically, call the HTTP API:
This returns JSON about the queue, including its message count.
Comparing the methods
| Method | Advantages | Disadvantages |
| Web Interface (Management Plugin) | Easy to use, visual interface, no coding required | Requires web access, less automation |
| HTTP API (Management Plugin) | Automatable, can integrate with systems | Requires enabling HTTP API, programmatic access |
rabbitmqctl Command Line Interface | Quick, does not require programming | Less flexible, limited to machine with access |
| Client Library (e.g., Pika for Python) | Full control, can be integrated into applications | Requires programming, more complex setup |
Related topics
- Security: Secure access to RabbitMQ with TLS/SSL connections and user permissions.
- Performance: Monitoring itself affects RabbitMQ's performance, so keep it light.
- Alerting and automation: Set up alerts on queue sizes and automate responses to them.
Related reading
- Check whether a Kafka topic exists in Python
- Checking the existence of topic in kafka before creating in Java
- Choosing the right cleanup policy in Kafka configuration
- Circuit breaker with kafka consumer
- Check stdvector has duplicates
- Checking for ambiguities in decision tree
- Clarification of use-cases for Hadoop versus RabbitMQ+Celery
- ClassNotFoundException org.apache.flink.streaming.api.checkpoint.CheckpointNotifier while consuming a kafka topic
System design interview problems on this topic
- Design a Distributed Messaging System: solution and walkthrough
- Design a Log Collection and Analysis System: solution and walkthrough
- Design an Ad Click Aggregation System: solution and walkthrough
- Design a Webhook Notification Service: solution and walkthrough

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseSystem Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.