MQ Commands Cheatsheet - Kafka/RabbitMQ/RocketMQ Reference

Most message queue incidents are chronic rather than dramatic: a consumer that silently stops, a backlog that keeps growing, or a connection count that only ever climbs. The triage order is consistent even though the commands differ per broker. Read the lag or queue depth first, then check how many consumers are registered and what state they are in, so you can tell "nobody is consuming" apart from "consuming too slowly". Then inspect the connection list to see whether the leak lives in the application pool or inside the broker. Kafka, RabbitMQ, RocketMQ and Redis Pub/Sub each report this differently, and Redis Pub/Sub is the odd one out: it has no backlog to inspect and drops messages while a consumer is disconnected, so the diagnostic question changes entirely. Commands are grouped by backlog, connections, cluster inspection and load testing, including throughput and record-count flags for perf tests. Treat a growing backlog as a symptom to be explained rather than a queue to be emptied, and take the message offset as the unit of investigation.

SysOps·32 commands·Last updated 2026-07-21
mqkafkarabbitmqrocketmqBackloglag

Kafka 6

kafka-consumer-groups.sh --bootstrap-server :9092 --list
List all consumer groups
kafka-consumer-groups.sh --describe --group <group>
View a group's lag and partition progress
kafka-topics.sh --describe --topic <topic>
View topic partitions, replicas and leader distribution
kafka-topics.sh --create --topic <t> --partitions 3 --replication-factor 2
Create a topic with given partitions and replication factor
kafka-console-producer.sh --topic <t> --bootstrap-server :9092
Produce messages from the CLI (for debugging)
kafka-console-consumer.sh --topic <t> --from-beginning --group <g>
Consume from the start and join a consumer group

RabbitMQ 6

rabbitmqctl list_queues name messages consumers
View queue backlog and consumer count
rabbitmqctl list_connections name state channels
View connections and channel count (leak check)
rabbitmqctl list_channels pid number
Find which connection holds many channels
rabbitmqctl cluster_status
View cluster nodes and partition state
rabbitmqadmin get queue=<q> count=1 ack=false
Peek at the head message without ack (debugging)
rabbitmqctl list_exchanges name type / list_bindings
View exchanges and bindings

RocketMQ 5

mqadmin consumerProgress -g <group>
View per-queue backlog progress of a consumer group
mqadmin topicList -m
View topic routing and queue distribution
mqadmin clusterList
View broker cluster status and roles
mqadmin brokerConsumeStats -b <addr> -g <group>
View consumption stats per broker
mqadmin queryMsgById -i <msgId>
Query a message by ID to trace losses

Redis Pub/Sub 5

PUBLISH channel "message"
Publish a message to a channel
SUBSCRIBE channel1 channel2
Subscribe to one or more channels
PSUBSCRIBE news.*
Subscribe to channels matching a pattern
PUBSUB CHANNELS *
List currently active channels
PUBSUB NUMSUB channel
View the subscriber count of a channel

General Backlog & Connection Checks 5

kafka-consumer-groups.sh --describe --group <g> --state
Check whether a group is rebalancing
rabbitmqctl node_health_check
Quick node health check (legacy command)
ss -tnp | grep :9092 | wc -l
Count connections to the broker (leak check)
du -sh /var/lib/kafka /var/lib/rabbitmq
Check MQ disk usage (watch water-mark alerts)
journalctl -u kafka --since "10 min ago"
View recent broker logs for OOM or throttling

Performance Testing & Benchmarking 5

kafka-consumer-perf-test.sh --bootstrap-server :9092 --topic <t> --messages 1000
Benchmark consumer throughput
kafka-producer-perf-test.sh --topic <t> --num-records 100000 --throughput -1
Benchmark producer throughput and latency
rabbitmq-perf-test --queue <q> --rate 1000 --producers 5
Official RabbitMQ benchmarking tool
redis-benchmark -h host -t publish,subscribe -n 100000
Redis Pub/Sub performance benchmark
kafka-consumer-groups.sh --describe --group <g> --members --verbose
View consumer-group members and assignments

Tips

  • For message backlog, first check lag and consumer count to tell slow consumers from too few — don't just purge the queue.
  • When hunting connection leaks, check both list_connections and the app's connection-pool config; looking at one side alone misleads.
  • Before restarting a broker, confirm messages are persisted; unflushed messages are lost.
  • In Kafka perf tests, --throughput -1 means uncapped; combine with --num-records for peak throughput.
  • Redis Pub/Sub is not persistent; messages during a disconnect are lost. Use Stream for reliable delivery.
  • When a RabbitMQ queue backs up, check the consumers column first; 0 means consumers aren't registered or have dropped.

Official References

Each command links to its official documentation below, so you can verify the latest usage and read deeper.

Maintained by LaoHand

Publicly updated on Jul 21, 2026, continuously proofread against official docs.

Contact Us

Wrong command or description? Send us corrections, business inquiries or product feedback by email.

Contact Us