Running RabbitMQ and the management UI

RabbitMQ · Essentials · 8 min

A local broker and a way to see what's inside it make every later lesson hands-on.

The quickest start is the official Docker image with the management plugin: rabbitmq:4-management. Important ports:

  • 5672: AMQP 0-9-1 (and AMQP 1.0) clients; 5671 with TLS.
  • 15672: the management UI and HTTP API.
  • 15692: Prometheus metrics (with the rabbitmq_prometheus plugin, enabled in the image).
  • 5552: the native stream protocol, if enabled.

The default user is guest / guest. Outside the Docker image it can only connect from localhost; in any real deployment, create proper users and delete guest.

The management UI shows connections, channels, exchanges and queues with message rates, ready and unacknowledged counts. You can publish and fetch test messages there, which is great for debugging.

Command-line tools run inside the node or container:

  • rabbitmqctl: node and object administration, e.g. list_queues name messages consumers.
  • rabbitmq-diagnostics: health checks such as check_running, status, ping.
  • rabbitmq-plugins enable <name>.
  • rabbitmqadmin (or the newer rabbitmqadmin v2 CLI) talks to the HTTP API.

Set RABBITMQ_DEFAULT_USER and RABBITMQ_DEFAULT_PASS for the container, and give it a fixed hostname: the node name and its data directory depend on it.

Example

docker run -d --name rabbit --hostname rabbit1 \
  -p 5672:5672 -p 15672:15672 \
  -e RABBITMQ_DEFAULT_USER=app -e RABBITMQ_DEFAULT_PASS=secret \
  -v rabbit-data:/var/lib/rabbitmq \
  rabbitmq:4-management
# UI: http://localhost:15672  (app / secret)

docker exec rabbit rabbitmq-diagnostics check_running
# RabbitMQ on node rabbit@rabbit1 is fully booted and running
docker exec rabbit rabbitmqctl list_queues name messages_ready messages_unacknowledged consumers
# name   messages_ready  messages_unacknowledged  consumers
# tasks  12              3                        2

Remember

  • 5672 for clients, 15672 for the UI and HTTP API
  • rabbitmqctl and rabbitmq-diagnostics administer a node
  • Set a fixed hostname and a volume so data survives restarts

Watch out for

  • Leaving guest/guest or default credentials on a reachable broker.

Check yourself

  1. In list_queues, what does messages_unacknowledged count?

Sign in to answer, see the explanations, and get this lesson back as a quick review later.

Official docs: www.rabbitmq.com/docs/download