• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

Magento 2 Rabbitmq configuration

by admin

Introduction

In November 2018, Magento 2.3.0 update quietly introduced integration with the message queue management tool RabbitMQ. The new feature opened powerful optimization options for both Magento 2 Commerce and Open Source editions.

Recently, We’ve talked about RabbitMQ installation and configuration. Now, We will show you how to configure Rabbitmq and use it on the installed Magento 2 instance.

Benefits

The main benefit of using RabbitMQ is the ability to decrease the load on the server during peak hours by storing data on the message broker. Before 2.3.0 only MySQL and cron were used for those purposes. But now We can use Rabbitmq which can speed up your current store by decreasing the load on MySQL database.

Rabbitmq installation

Rabbitmq installation is described in our article RabbitMQ installation and configuration. Which can be used to install RabbitMQ on your Ubuntu or CentOS server.

Rabbitmq configuration

1. First of all need to remove guest user:

# rabbitmqctl delete_user guest

2. After that we will need to create user with needed permissions.

# rabbitmqctl add_user rabbitmq rabbitmq_pwd
# rabbitmqctl set_user_tags rabbitmq administrator
# rabbitmqctl set_permissions -p / rabbitmq ".*" ".*" ".*"

3. Also, We need to create queue:

# rabbitmqadmin --username=rabbitmq --password=rabbitmq_pwd declare queue --vhost=/ name=async.operations.all durable=true

That’s all, rabbitmq is ready to use. From now, We can start to configure Magento to use it.

Magento configuration

First of all, We need to add rabbitmq configuration. It can be done in 2 ways:

Via bin/magento

$ php bin/magento setup:config:set --amqp-host="127.0.0.1" --amqp-port="5672" --amqp-user="rabbitmq" --amqp-password="rabbitmq_pwd" --amqp-virtualhost="/"

By editing app/etc/env.php with following lines

'queue' =>
  array (
    'amqp' =>
    array (
      'host' => '127.0.0.1',
      'port' => '5672',
      'user' => 'rabbitmq',
      'password' => 'rabbitmq_pwd',
      'virtualhost' => '/'
     ),
  ),

Also, you’ll need to add cron runner to app/etc/env.php:

'cron_consumers_runner' => [
  'cron_run' => true,
  'max_messages' => 0,
  'consumers' => [
    'async.operations.all',
    'codegeneratorProcessor'
  ]
]

That’s all. We successfully configured rabbitmq consumer in Magento.

Testing rabbitmq consumer on Magento

To list all consumers you can run command:

# php bin/magento queue:consumers:list

To run consumer you need to run following command:

# php bin/magento  queue:consumers:start  async.operations.all

That’s all. The consumer should work now!

Conclusion

RabbitMQ is a powerful message broker which can help to improve your store speed. Also, it will be helpful to decrease the load on your MySQL server which can be helpful during load spikes.

Filed Under: Linux

Some more articles you might also be interested in …

  1. pvcreate error : Can’t open /dev/sdx exclusively. Mounted filesystem?
  2. mkpasswd Command Examples in Linux
  3. Configuring Persistent Storage in CentOS/RHEL 5,6 for Single Path using udev rules
  4. Understanding /proc/meminfo file (Analyzing Memory utilization in Linux)
  5. LVM Snapshot: Backup and restore LVM Partition in Linux
  6. How to Install Cockpit’s Web Console in CentOS/RHEL 8
  7. How to Create/Format/Extend Virtual Data Optimizer(VDO) Volumes using Cockpit Web Console in CentOS/RHEL 8
  8. 14 Useful “cat” Command Examples in Linux
  9. Unable to Start RDMA Services on CentOS/RHEL 7
  10. UNIX / Linux : Send mail with attachment using mutt

You May Also Like

Primary Sidebar

Recent Posts

  • JavaFX ComboBox: Set a value to the combo box
  • Nginx load balancing
  • nginx 504 gateway time-out
  • Images preview with ngx_http_image_filter_module

© 2022 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright