• 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. ORA-01031: insufficient privileges when creating a materialized view
  2. arp: command not found
  3. How to make CentOS/RHEL 7 FIPS 140-2 compliant
  4. repo-add: command not found
  5. “java” command does not run the JVM that has been installed
  6. modprobe: command not found
  7. ansible-inventory – Display or dump an Ansible inventory (Command Examples)
  8. How to Configure Multiple MySQL Servers On One System Using mysqld_multi
  9. How to allow only specific non-root user(s) to use crontab
  10. fsck: command not found

You May Also Like

Primary Sidebar

Recent Posts

  • aws ec2: CLI for AWS EC2 (Command Examples)
  • aws cur – Create, query, and delete AWS usage report definitions (Command Examples)
  • aws configure – Manage configuration for the AWS CLI (Command Examples)
  • aws cognito-idp: Manage Amazon Cognito user pool and its users and groups using the CLI

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright