Skip to main content

RabbitMQ

RabbitMQ is a message broker: one program publishes messages, others consume them, and the broker holds them in between. On this platform your messages live in virtual hosts (vhosts) — private namespaces for your exchanges and queues.

1. Create a user

  1. Go to Services and click Manage on RabbitMQ.
  2. Click Add User (or Create User if you have none yet).
  3. Fill in Username, Password and Confirm Password.
  4. Choose a User Privilege, then confirm.
The Add User Details dialog with Username, Password, Confirm Password and the User Privilege dropdown showing Publish User and Subscribe User.
PrivilegeCanUse it for
Publish UserConfigure, write and read — full access to your vhostsBack-end code that publishes messages
Subscribe UserConfigure and read — can consume, cannot publishCode that only listens, including front-end code where the credentials could be seen
Keep publish credentials on the server side

Anyone holding a Publish User's password can write to your exchanges and queues. If credentials have to ship to a browser or a device you do not control, use a Subscribe User.

Username and password follow the same rules as the other services: 5–16 characters of letters, digits and underscores for the name; at least 8 characters and no single quotes for the password.

2. Create a virtual host

  1. Open the Virtual Host tab.
  2. Type a Virtual Host Name. It is prefixed with your platform username and an underscore, shown in front of the field.
  3. Click Create Virtual Host.

Virtual Hosts Usage shows how many you have used; the limit is 5. Every RabbitMQ user you create gets access to your virtual hosts, with the permissions of its privilege. Drop on a vhost card deletes it and everything in it.

3. Connect from your lab

The service card and the Connection Information panel list the host and the ports, each labelled with what it is for. Copy the AMQP host and port, then connect with any AMQP client:

amqp://<user>:<password>@<host>:<port>/<vhost>

<vhost> is the full name including your prefix.

A minimal publisher in Python:

import pika # pip install pika

params = pika.URLParameters("amqp://<user>:<password>@<host>:<port>/<vhost>")
conn = pika.BlockingConnection(params)
ch = conn.channel()
ch.queue_declare(queue="tasks")
ch.basic_publish(exchange="", routing_key="tasks", body=b"hello")
conn.close()

And a consumer, which works with a Subscribe User once the queue exists:

import pika

params = pika.URLParameters("amqp://<user>:<password>@<host>:<port>/<vhost>")
conn = pika.BlockingConnection(params)
ch = conn.channel()
ch.basic_consume(queue="tasks", auto_ack=True,
on_message_callback=lambda c, m, p, body: print(body))
ch.start_consuming()

If it does not work

SymptomCheck
ACCESS_REFUSED on loginUser name and password copied from the card; the vhost name includes your prefix
ACCESS_REFUSED when publishingThe user is a Subscribe User — publish with a Publish User
NOT_FOUND for a vhostThe vhost exists on the Virtual Host tab and you used its full name

Next