Skip to content

Instantly share code, notes, and snippets.

@fredjoseph
Last active January 5, 2024 06:35
Show Gist options
  • Select an option

  • Save fredjoseph/8aac40b04a170990e31b5824fdcf35f1 to your computer and use it in GitHub Desktop.

Select an option

Save fredjoseph/8aac40b04a170990e31b5824fdcf35f1 to your computer and use it in GitHub Desktop.
RabbitMQ

RabbitMQ

rabbitmqadmin

  • Get a list of exchanges for the specified vhost rabbitmqadmin -V / list exchanges
  • Get a list of queues, with some columns specified rabbitmqadmin list queues vhost name node messages message_stats.publish_details.rate
  • Get a list of queues with all details we can take rabbitmqadmin -f long -d 3 list queues
  • Publish a message rabbitmqadmin publish exchange=amq.default routing_key=test payload="hello, world"
  • Get it back rabbitmqadmin get queue=test ackmode=ack_requeue_false
  • Export Configuration (Definitions) rabbitmqadmin export rabbit.definitions.json

rabbitmqctl

  • rabbitmqctl -l to list commands
  • rabbitmqctl status to show memory
  • rabbitmqctl stop_app and rabbitmqctl start_app
  • rabbitmqctl reset and rabbitmqctl force_reset
  • rabbitmqctl rotate_logs
  • rabbitmqctl join_cluster join a cluster as either a disc (default) or ram only
  • rabbitmqctl purge_queue <queue> to remove all messages in it
  • rabbitmqctl list_queues
  • rabbitmqctl list_exchanges

rabbitmq-plugins

  • rabbitmq-plugins list to see what plugins are enabled
  • rabbitmq-plugins enable <plugin-name> to enable a plugin
  • rabbitmq-plugins disable <plugin-name> to disable a plugin

Plugin List

  • rabbitmq_auth_backend_http - authentication / authorisation plguin that uses an external HTTP API
  • rabbitmq_management - a management / monitoring API over HTTP, along with a browser-based UI (I use this all the time)
  • rabbitmq_shovel - a plugin that shovels messages from a queue on one broker to an exchange on another broker
  • rabbitmq_tracing - provides a GUI to capture traced messages and log them in text or JSON format
  • rabbitmq-top is used to analyze node memory use
  • rabbitmq-mqtt - lightweight messaging protcol for small sensors and mobile devices; good for high-latency or unreliable networks

debugging

  • Start debugging
  1. Install missing plugins
# Enable web console
sudo rabbitmq-plugins enable rabbitmq_management
# Enable tracing pluging
sudo rabbitmq-plugins enable rabbitmq_tracing
# Add a super admin user
sudo rabbitmqctl add_user admin password
sudo rabbitmqctl set_user_tags admin administrator
sudo rabbitmqctl set_permissions -p / admin ".*" ".*" ".*"
# restart RabbutMQ server
systemctl restart rabbitmq-server
  1. Run sudo rabbitmqctl trace_on
  2. Go to http://localhost:15672/#/traces/ and create a topic queue for trace messages. The pattern can be # to capture all messages or a topic in the form of publish.[exchange name] or deliver.[queue name] to trace messages published through a particular exchange or consumed from a particular queue. Clicking on the log name will bring up the log The log files are located to /var/tmp/rabbitmq-tracing
  • Stop debugging
  1. Run sudo rabbitmqctl trace_off
  2. Delete the trace logs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment