Skip to content

Configuring RabbitMQ

The RabbitMQ message broker service can be enabled in your Stratus panel in the RabbitMQ > Info panel.

The credentials shown in the [RabbitMQ > Configuration][6d] panel may be changed, but must match the ones configured in env.php.

These are only used on the initial deploy of RabbitMQ. If these credentials are changed after starting RabbitMQ, it will not affect the existing user.

RabbitMQ Configuration

Below is an example configuration of the env.php file. Please note that on a production instance the host will be rabbitmq; on a development instance the host will be 0.0.0.0.

'cron_consumers_runner' => [
        'cron_run' => true,
        'max_messages' => 0,
        'consumers' => [
            'async.operations.all',
            'codegeneratorProcessor',
            'product_action_attribute.update',
            'product_action_attribute.website.update',
            'exportProcessor'
        ]
    ],
    'queue' => [
        'amqp' => [
            'host' => 'rabbitmq',
            'port' => '5672',
            'user' => 'username',
            'password' => 'yb2sovjbaa4atsbbn0s0ccm9uddekh6i',
            'virtualhost' => '/',
            'ssl' => 'false',
            'ssl_options' => []
        ]
    ]

To see a list of available consumers that you can set to run, use:

php bin/magento queue:consumers:list

Advanced Usage

RabbitMQ ships with command line and other management utilities. Depending on the exact usage of RabbitMQ, these tools may be used to debug and investigate certain issues with a Magento install. To call RabbitMQ procedures from the command line use the rabbitmqadmin utility.

For example, to list the existing users:

$ rabbitmqadmin --host rabbitmq -u kermit -p wakkawakka1234 list users 
+--------+--------------------------------+--------------------------------------------------+---------------+
|  name  |       hashing_algorithm        |                  password_hash                   |     tags      |
+--------+--------------------------------+--------------------------------------------------+---------------+
| kermit | rabbit_password_hashing_sha256 | 7YJGqcUKDcnvFkxwMOq+4OLCZw8RrYZL5sOGTAz2vXdXkLBF | administrator |
+--------+--------------------------------+--------------------------------------------------+---------------+

The official RabbitMQ documentation has various examples of how to use the rabbitmqadmin admin tool. On Mojo Stratus, use the correct host and user in all your commands. As with the env.php configuration, the host will always be rabbitmq or 0.0.0.0.

Web Interface.

The RabbitMQ management plugins are enabled in Mojo Stratus, and can be accessed using the correction configurations.

The Web UI is always running, but can only be accessed one of two ways:

  1. Use an SSH tunnel to expose the web interface on a local port
  2. Set up a proxy pass directive in the Stratus Nginx configuration

SSH Tunnel

An SSH tunnel is the most secure way to access the RabbitMQ UI.

  1. To access the RabbitMQ UI, make sure an SSH user is configured for the Stratus instance.
  2. Via terminal, run the following command with the correct user/host/port information to open a tunnel:

    ssh -p <port> <user>@<ssh-endpoint>.mojostratus.io -L 15672:rabbitmq:15672
    

    Change rabbitmq to 0.0.0.0, if you are using autoscaling.

  3. With the tunnel connected, open a local browser to http://localhost:15672/.

    RabbitMQ Login Panel

  4. Enter the username/password configured for RabbitMQ in your initial start-up (under RabbitMQ -> Configuration)

Read the official docs for more details on how to use and interpret the UI..

Nginx Proxy Pass

Although not recommended, an Nginx Proxy Pass may be used for quick access. It is also recommend that the location be secured by IP whitelist if the intention is to leave the UI permanently exposed.

  1. Go to Nginx > Includes in the Stratus panel.
  2. Add a new location directive similar to this:

    location /yourrabbitadmin/ {
        proxy_pass http://rabbitmq:15672/;
    }
    
  3. Click Update to save the changes.

The RabbitMQ UI can now be accessed at https://mysite.com/yourrabbitadmin.

Resetting Data

In the [RabbitMQ > Info][4d] panel the data can be reset if needed to wipe the service clean of all data.

RabbitMQ data is persistent, similar to MySQL. Persistent data is important since some stores may use RabbitMQ to store important data like order data until it is later saved within the Magento MySQL data.