Skip to content

Instantly share code, notes, and snippets.

@lukebakken
Created October 31, 2025 14:30
Show Gist options
  • Select an option

  • Save lukebakken/1daf509e4eb93396b5ede27027237332 to your computer and use it in GitHub Desktop.

Select an option

Save lukebakken/1daf509e4eb93396b5ede27027237332 to your computer and use it in GitHub Desktop.

RabbitMQ 4.0.5 Consumer Count Discrepancy Analysis

Summary

When rabbitmqctl list_consumers -q | wc -l reports a significantly lower number of consumers than the Management UI → Global counts → Consumers, the mismatch is usually due to one or more of the following factors.


1. CLI Limits to a Single VHost

rabbitmqctl list_consumers operates on a single vhost, often /, unless you specify -p <vhost>.
The Management UI aggregates all visible vhosts in its global consumer count.

Verification Command:

rabbitmqctl list_vhosts -q | xargs -I{} sh -c 'printf "%s\t" "{}"; rabbitmqctl list_consumers -q -p "{}" | wc -l' | awk '{s+=$2} END{print "SUM:", s}'

Reference: RabbitMQ Management API – Overview (object_totals)


2. Streams vs Queues

The Management API exposes both:

  • /api/consumers → AMQP queue consumers
  • /api/stream/consumers → Stream protocol consumers

The UI’s global “Consumers” likely includes both, while rabbitmqctl list_consumers reports only AMQP queue consumers.

Verification: Compare counts from both API endpoints.

Reference: Management API – /api/consumers and /api/stream/consumers


3. Partial Cluster Visibility

rabbitmqctl list_consumers performs RPC fan-out across cluster nodes. If any node is slow, partitioned, or down, the result may be partial, missing consumers from those nodes.

Verification:

rabbitmqctl cluster_status
rabbitmqctl list_consumers -n <another-node>

Reference: RabbitMQ CLI Cluster Commands


4. Stats DB Lag or Duplication

The Management plugin aggregates asynchronously. During heavy consumer churn (auto-recovery, frequent connects/disconnects), the stats DB can temporarily overcount.

Verification:
Check /api/overview for statistics_db_event_queue. A large value indicates backlog.

Reference: Management Plugin Statistics DB


5. Non-AMQP Protocol Consumers

The UI’s total may include AMQP 1.0, MQTT, or STOMP receivers, which are not visible to rabbitmqctl list_consumers.

Verification:
Inspect /api/connections and /api/channels for non-AMQP protocols.


6. Internal Plugin Consumers

Federation, Shovel, and monitoring agents create broker-side consumers spread across vhosts and nodes. These appear in the UI but may be unevenly represented in CLI output if filters are applied.

Verification:
List per-vhost consumers and inspect arguments identifying internal tools.


Recommended Diagnostics

  1. Sum per-vhost consumer counts (likely explains most discrepancies).
  2. Add stream consumers from /api/stream/consumers.
  3. Confirm all cluster nodes respond to CLI queries.
  4. Inspect stats DB backlog in /api/overview.

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment