RabbitMQ: get the number of messages in a queue
Codemia Knowledge Hub ·
On the broker host, run rabbitmqctl list_queues name messages messages_ready messages_unacknowledged. The messages column is the total in each queue, which is usually what "total enqueued" means. RabbitMQ reports ready and unacknowledged messages separately, and that split matters when you diagnose a backlog.
Counting with rabbitmqctl
The columns are:
messages: total messages visible to the queuemessages_ready: messages waiting to be deliveredmessages_unacknowledged: messages delivered to consumers but not yet acknowledged
For a single queue:
This is often enough for operational checks and debugging.
Reading the breakdown
messages includes both ready and unacknowledged messages, so it does not mean "messages waiting to be processed". A queue showing messages = 5000 is not a diagnosis on its own:
- A high
messages_readymeans consumers are not keeping up. - A high
messages_unacknowledgedmeans consumers may be slow, stuck or not acknowledging correctly.
Counting through the management HTTP API
With the management plugin enabled, the HTTP API is often the easiest option for scripts and monitoring. This returns JSON for all queues:
For one queue, add its virtual host and name:
%2F is the URL-encoded default virtual host /. The fields to read are messages, messages_ready and messages_unacknowledged. Make sure you query the right virtual host: the same queue name can exist in several of them.
Counting from application code
Many client libraries can declare a queue passively and read the count from the result. In Python with Pika:
A passive declare asks RabbitMQ about the queue without changing its definition, which suits diagnostics, health checks and admin tooling. Keep it out of hot application paths, where it adds unnecessary broker calls; poll deliberately for monitoring instead.
Totaling all queues
To get the backlog across every queue, sum the messages column:
A single global number can hide one failing queue among healthy ones. Track both per-queue depth (for diagnosis) and aggregate depth (for capacity trends).
Watching counts over time
For ongoing operations, the management UI, Prometheus exporters and dashboards are better than one-off CLI checks. Knowing whether a queue is rising, draining or stuck is usually more useful than a single snapshot.
Related reading
- RabbitMQ - How many queues can RabbitMQ handle on a single server?
- RabbitMQ - Message order of delivery
- Rabbitmq - multiple binding ( routing keys ) to a single queue
- RabbitMQ - Multiple instances reading from the same Topic
- RabbitMQ - purge a queue from all of its unacked messages
- Rabbitmq - queues state shows as ''running'' , GUI shows status as IDLE
- RabbitMQ - Random queues with name amq.gen-* getting autogenerated
- RabbitMQ - Send a JSON message
Course lessons on this
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.