Skip to main content
Blog Magento 2

Rabbitmq Configuration with Magento 2

Divya Sree
July 26, 2021 |

RabbitMQ Configuration

Want to grasp the nuances of RabbitMQ? If so, you’re at the right place. RabbitMQ can help to transfer tasks into queues and get them processed at a time or as parallel processing through asynchronous messaging, thereby allowing web servers to respond quickly. In this blog, we can learn how to configure RabbitMQ with Magento 2.

What is RabbitMQ?

Magento 2 RabbitMQ works as a message intermediator between sender and receiver. It is an open-source communication broker that provides your applications with a common platform while offering a secure and convenient messaging system. It offers a highly reliable, scalable, and portable messaging system. Magento 2 added asynchronous messaging capabilities with the implementation of RabbitMQ. Message Queuing allows web servers to respond quickly to requests and represent them to a third party for processing rather than perform the task instantaneously. This helps in handling multiple, resource-intensive requests efficiently. Several activities are being performed within a website’s architecture as a customer places an order from the website. These are:

  • Generating the order
  • Taking payment
  • Stock management
  • Enabling email and text communications
  • Sending/Receiving order data to SAP/CRM/ERP systems

When all these activities are performed in real-time, more time is consumed to complete the order process, which can have a negative impact on business. Here comes RabbitMQ, which can help to transfer most of these tasks into queues and get them processed at a time or as parallel processing through asynchronous messaging, thereby allowing web servers to respond quickly. RabbitMq is a message queue system. It will process at a time or in parallel. If anything goes wrong, it will not directly impact the Magento Instance.

Benefits of RabbitMQ

  • Asynchronous Messaging
  • Highly Available Queues
  • Management UI
  • Plugin System

The following diagram illustrates the Message Queue Framework:RabbitMQ Configuration frameworkA publisher is a component that sends messages to an exchange. It knows which exchange to publish to and the format of the messages it sends. An exchange receives messages from publishers and sends them to a queue. A queue is a buffer that stores messages. A consumer receives messages. It knows which queue to consume. It can map the processors of the message to a specific queue.

Connect RabbitMQ to Magento Open Source or Adobe Commerce

Here’s the process to set up RabbitMQ to our Magento instance:

STEP -1  

Add Queue Configuration 

Add a queue section in the /app/etc/env.php file so that it is similar to the following:

‘queue’ =>

array (   

‘amqp’ =>   

array (     

‘host’ => ‘192.XXX.XX.XX’, (This needs to be updated as per your project IP)

‘port’ => ‘15672’, (Port on which RabbitMQ runs. 15672 is default port)

‘user’ =>’test’,     

‘password’ => ‘magento’,     

‘virtualhost’ => ‘/’   



Step 2  

Open the terminal and change the directory to your Magento root path.

Step 3 

Add RabbitMQ user

Run the below command to set the RabbitMQ user.Syntax :

sudo rabbitmqctl add_user {user_name} {passwd}Sample: sudo rabbitmqctl add_user test magento

Step 4 

Set RabbitMQ user Role

Run the below command to set the RabbitMQ user role.

Syntax : sudo rabbitmqctl set_user_tags {user_name} administrator

Sample: sudo rabbitmqctl set_user_tags test administrator

Step 5 Set RabbitMQ User Role Permissions

Run the below command to set the RabbitMQ user role permissions.

Syntax : sudo rabbitmqctl set_permissions -p / {user_name} “.*” “.*” “.*”

Sample: sudo rabbitmqctl set_permissions -p /  test “.*” “.*” “.*”

Step 6

Then, run bin/Magento setup: upgrade to apply the changes.

Step 7 

To access the RabbitMQ Admin-

Use this URL to access the RabbitMQ AdminSyntax: http://Your_Server_IP:15672/Sample:http://192.XXX.XX.XX:15672/ RabbitMQ Configuration stepsEnter the Username and Password to log into RabbitMQ Admin.RabbitMQ Configuration stepsHurray! You have now connected the Magento instance and the RabbitMQ. You are all set to begin the message queue consumers!

Final Thoughts

Upgrading your eCommerce website with the latest technology definitely requires you to put a lot of thought into the process. Not only should you find the best development services possible but also requires you to grab onto adequate maintenance support. So what if you get both high-grade Magento development services and maintenance support under one roof? In the 15+ years of experience in digital commerce, DCKAP has helped several distributors and manufacturers to digitally transform their B2B ventures. Our diligent team of Magento experts builds and designs result-yielding Magento storefronts. Apart from the maintenance services, our cutting-edge integration solutions connect leading eCommerce platforms like Magento with ERP, CRM, and other applications. But our services just don’t end here. To learn more, feel free to reach out to our team and grow your eCommerce with us.

Divya Sree

Divya Sree Ravi is a Software Engineer at DCKAP, who is passionate about Magento. With 2+ years of experience, she is an Adobe Certified Professional - Adobe Commerce Developer. When she is not coding, you can find her in the midst of books, listening to music, or watching science-fiction movies.

More posts by Divya Sree