How to Install and Connect RabbitMQ to Magento 2
It is software where queues are characterized, to which applications interface with transfer a message or messages.
A message can incorporate any data. For instance, it could have data about a cycle or assignment that should begin another application or only a straightforward instant message.
The line manager software stores the message until a receiver connects and takes a message off the queue. The accepting application at that point measures the message.
You must install the message queue system before you install Magento. The working order should be...
- Install RabbitMQ and any prerequisites
- Connect RabbitMQ and Magento
Table of Contents :
-
Recommended installation options of RabbitMQ for Windows:
Installing RabbitMQ as an administrative user.
Every time the RabbitMQ releases a version, they produce an official installer for convenience.
This allows Windows users with the most adaptability, but at the same time, Windows users need to be conscious of particular assumptions and obligations in the installer:
The following are some assumptions that need to be taken care of.
- There should be only one Erlang version installed at a time.
- Erlang needs to be installed as an administrative account.
- RabbitMQ must also be installed as an administrative account.
- The installation path should only include ASCII characters.
- It may be crucial to copy the shared secret file used by CLI tools manually.
- CLI tools require Windows console to operate in UTF-8 mode
- If these requirements are not satisfied, the Windows service and CLI tools may require reinstallation or other manual steps to bring them to function as expected.
Also Read: How To Check Your Magento Version
-
Configure RabbitMQ
Although RabbitMQ has its built-in default settings, which are utterly sufficient for some environments, e.g., development and QA.
Apart from these, if you need to configure for other cases, there is a way to set up several broker and plugins factors.
You can manage the following variables as per your need and requirement.
- 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,
- --amqp-host, is the hostname where RabbitMQ is installed.
- --amqp-port, is the port to use to connect to RabbitMQ. The default is 5672.
- --amqp-user, is the username for connecting to RabbitMQ. Try not to use the default user guest.
- --amqp-password, is the password for connecting to RabbitMQ. Try not to use the default password guest.
- --amqp-virtual host, is the virtual host for connecting to RabbitMQ. The default is /.
- --amqp-ssl, is indicating whether to connect to RabbitMQ. The default is false. In case you set true, please check to configure SSL, further in this guide.
-
Connect RabbitMQ to Magento Open Source or Magento Commerce
In case you already have the Magento installed with you. and want to connect it to RabbitMQ, all you need to do is add a queue section in the <install_directory>/app/etc/env.php file. It will look similar to the following:
'queue' =>array ( 'amqp' => array ( 'host' => 'rabbitmq.example.com', 'port' => '11213', 'user' => 'magento', 'password' => 'magento', 'virtualhost' => '/' ),),
Once you do this, hit, run bin/Magento setup: now upgrade to apply the changes, and now you are ready to create the required queues in RabbitMQ.
-
Configure SSL
To configure SSL support, you will be required to edit the SSL and ssl_options parameters in the <install_directory>/app/etc/env.php file. It will look similar to the following:
'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'
],
),
),After you have connected Magento Commerce and RabbitMQ, You are all set to begin the message queue consumers.
-
Conclusion:
So, in the end, we can conclude that Magento 2.0 provides a handy tool to work with queues - RabbitMQ.
Hope we were able to explain the implementation of RabbitMQ in Magento 2 briefly. Please share your thoughts in the comment section.