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.
Kafka 6
kafka-consumer-groups.sh --bootstrap-server :9092 --listkafka-consumer-groups.sh --describe --group <group>kafka-topics.sh --describe --topic <topic>kafka-topics.sh --create --topic <t> --partitions 3 --replication-factor 2kafka-console-producer.sh --topic <t> --bootstrap-server :9092kafka-console-consumer.sh --topic <t> --from-beginning --group <g>RabbitMQ 6
rabbitmqctl list_queues name messages consumersrabbitmqctl list_connections name state channelsrabbitmqctl list_channels pid numberrabbitmqctl cluster_statusrabbitmqadmin get queue=<q> count=1 ack=falserabbitmqctl list_exchanges name type / list_bindingsRocketMQ 5
mqadmin consumerProgress -g <group>mqadmin topicList -mmqadmin clusterListmqadmin brokerConsumeStats -b <addr> -g <group>mqadmin queryMsgById -i <msgId>Redis Pub/Sub 5
PUBLISH channel "message"SUBSCRIBE channel1 channel2PSUBSCRIBE news.*PUBSUB CHANNELS *PUBSUB NUMSUB channelGeneral Backlog & Connection Checks 5
kafka-consumer-groups.sh --describe --group <g> --staterabbitmqctl node_health_checkss -tnp | grep :9092 | wc -ldu -sh /var/lib/kafka /var/lib/rabbitmqjournalctl -u kafka --since "10 min ago"Performance Testing & Benchmarking 5
kafka-consumer-perf-test.sh --bootstrap-server :9092 --topic <t> --messages 1000kafka-producer-perf-test.sh --topic <t> --num-records 100000 --throughput -1rabbitmq-perf-test --queue <q> --rate 1000 --producers 5redis-benchmark -h host -t publish,subscribe -n 100000kafka-consumer-groups.sh --describe --group <g> --members --verboseTips
- 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