This is a beta release of documentation for Magento 2.4, published for previewing soon-to-be-released functionality. Content in this version is subject to change. Links to the v2.4 code base may not properly resolve until the code is officially released.
You must install Elasticsearch before installing Magento Commerce or Magento Open Source 2.4.0. See Elasticsearch for details.

RabbitMQ

RabbitMQ Overview

RabbitMQ is an open source message broker that offers a reliable, highly available, scalable and portable messaging system.

Message queues provide an asynchronous communications mechanism in which the sender and the receiver of a message do not contact each other. Nor do they need to communicate with the message queue at the same time. When a sender places a messages onto a queue, it is stored until the recipient receives them.

The message queue system must be established before you install Magento. The basic sequence is

  1. Install RabbitMQ and any prerequisites.
  2. Connect RabbitMQ and Magento.

You can use MySQL or RabbitMQ for message queue processing. For details on setting up the message queue system, see Message queues overview. If you are using the Bulk API with Magento Commerce, the message queue system configuration defaults to using RabbitMQ as the message broker. See Start message queue consumers for more information.

Install RabbitMQ on Ubuntu

To install RabbitMQ on Ubuntu 16 enter the following command:

1
sudo apt install -y rabbitmq-server

This command also installs the required Erlang packages.

If you have an older version of Ubuntu, RabbitMQ recommends installing the package from their website.

  1. Download the .deb package from rabbitmq-server.
  2. Install the package with dpkg.

Refer to Installing on Debian/Ubuntu for more information.

Install RabbitMQ on CentOS

Install Erlang

RabbitMQ was written using the Erlang programming language, which must be installed on the same system as RabbitMQ.

See Manual installation for more information.

Refer to the RabbitMQ/Erlang version matrix to install the correct version.

Install RabbitMQ

The RabbitMQ server is included on CentOS, but the version is often old. RabbitMQ recommends installing the package from their website.

Refer to the RabbitMQ install page to get the latest supported vesion. Magento 2.3 supports RabbitMQ 3.8.x.

Refer to Installing on RPM-based Linux for more information.

Configure RabbitMQ

Review the official RabbitMQ documentation to configure and manage RabbitMQ. Pay attention to the following items:

  • Environment variables
  • Port access
  • Default user accounts
  • Starting and stopping the broker
  • System limits

Install Magento with RabbitMQ and connect to Magento Open Source or Magento Commerce

If you installed Magento after you installed RabbitMQ, add the following command line parameters when you install Magento Open Source or Magento Commerce:

--amqp-host="<hostname>" --amqp-port="5672" --amqp-user="<user_name>" --amqp-password="<password>" --amqp-virtualhost="/"

where:

Parameter Description
--amqp-host The hostname where RabbitMQ is installed.
--amqp-port The port to use to connect to RabbitMQ. The default is 5672.
--amqp-user The username for connecting to RabbitMQ. Do not use the default user guest.
--amqp-password The password for connecting to RabbitMQ. Do not use the default password guest.
--amqp-virtualhost The virtual host for connecting to RabbitMQ. The default is /.
--amqp-ssl Indicates whether to connect to RabbitMQ. The default is false. If you set the value to true, see Configure SSL for more information.

Connect RabbitMQ to Magento Open Source or Magento Commerce

If you already had Magento installed and you want to connect it to RabbitMQ, add a queue section in the <install_directory>/app/etc/env.php file so that it is similar to the following:

1
2
3
4
5
6
7
8
9
10
11
'queue' =>
  array (
    'amqp' =>
    array (
      'host' => 'rabbitmq.example.com',
      'port' => '11213',
      'user' => 'magento',
      'password' => 'magento',
      'virtualhost' => '/'
     ),
  ),

Then, run bin/magento setup:upgrade to apply the changes and create the required queues in RabbitMQ.

Configure SSL

To configure support for SSL, edit the ssl and ssl_options parameters in the <install_directory>/app/etc/env.php file so that they are similar to the following:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
'queue' =>
  array (
    'amqp' =>
    array (
      'host' => 'rabbitmq.example.com',
      'port' => '11213',
      'user' => 'magento',
      'password' => 'magento',
      'virtualhost' => '/',
      'ssl' => 'true',
      'ssl_options' => [
            'cafile' =>  '/etc/pki/tls/certs/DigiCertCA.crt',
            'certfile' => '/path/to/magento/app/etc/ssl/test-rabbit.crt',
            'keyfile' => '/path/to/magento/app/etc/ssl/test-rabbit.key'
       ],
     ),
  ),

Start the message queue consumers

After you have connected Magento Commerce and RabbitMQ, you must start the message queue consumers. See Configure message queues for details.

Related topics