RabbitMQ (Message Queue service)

RabbitMQ is an open source message broker software (sometimes called message-oriented middleware) that implements the Advanced Message Queuing Protocol (AMQP).

See the RabbitMQ documentation for more information.

Supported versions

  • 3.5
  • 3.6
  • 3.7


The format exposed in the $PLATFORM_RELATIONSHIPS environment variable:

   "rabbitmq" : [
         "password" : "guest",
         "ip" : "",
         "scheme" : "amqp",
         "port" : 5672,
         "host" : "rabbitmq.internal",
         "username" : "guest"

Usage example

In your .platform/services.yaml:

    type: rabbitmq:3.7
    disk: 1024

In your .platform.app.yaml:

    mq: "myrabbitmq:rabbitmq"

You can then use the service in a configuration file of your application with something like:

// This assumes a fictional application with an array named $settings.
    $relationships = json_decode(base64_decode($relationships), TRUE);

    // For a relationship named 'mq' referring to one endpoint.
    if (!empty($relationships['mq'])) {
        foreach ($relationships['mq'] as $endpoint) {
            $settings['rabbitmq_host'] = $endpoint['host'];
            $settings['rabbitmq_port'] = $endpoint['port'];

(The specific way to inject configuration into your application will vary. Consult your application or framework's documentation.)

Connecting to RabbitMQ

From your local development environment

For debugging purposes, it's sometimes useful to be able to directly connect to a service instance. You can do this using SSH tunneling. To open a tunnel, log into your application container like usual, but with an extra flag to enable local port forwarding:

ssh -L 5672:mq.internal:5672 <projectid>-<branch_ID>@ssh.eu.platform.sh

Within that SSH session, use the following command to pretty-print your relationships. This lets you see which username and password to use, and you can double check that the remote service's port is 5672.

php -r 'print_r(json_decode(base64_decode($_ENV["PLATFORM_RELATIONSHIPS"])));'

If your service is running on a different port, you can re-open your SSH session with the correct port by modifying your -L flag: -L 5672:mq.internal:<remote port>.

Finally, while the session is open, you can launch a RabbitMQ client of your choice from your local workstation, configured to connect to localhost:5672 using the username and password you found in the relationship variable.

From the application container

The application container currently doesn't include any useful utilities to connect to RabbitMQ with. However, you can install your own by adding a client as a dependency in your .platform.app.yaml file.

For example, you can use amqp-utils by adding this:

    amqp-utils: "0.5.1"

Then, when you SSH into your container, you can simply type any amqp- command available to manage your queues.