Docs: Overview of RabbitMq

RabbitMQ is an AMQP-based message broker that Magento 2 uses for asynchronous processing, background tasks, and scalable messaging. It improves performance by offloading heavy processes from the frontend.


What is RabbitMQ?

RabbitMQ is a message queue system that allows Magento to send tasks into queues, where consumers process them asynchronously.

Key Benefits
  • Improves performance by moving heavy tasks to background
  • Decouples systems (producers & consumers)
  • Scalable message handling
  • Reliable with retries and persistence
  • Used by many Magento core modules

Where Magento Uses RabbitMQ

1. Asynchronous Orders

Orders can be placed asynchronously to reduce checkout load.

Checkout → Message Queue → Consumer → Order Save
2. Inventory (MSI)

Handles stock reservation updates asynchronously.

3. Email Sending

Transactional emails can be queued for faster processing.

4. Data Export / Import

Large admin operations use queue processing.

5. Cron Offloading

Heavy cron tasks are handled via message queues.


Message Queue Architecture

 Producer → Exchange → Queue → Consumer

  
Terms
  • Producer: Magento module publishing messages
  • Exchange: RabbitMQ router
  • Queue: Stores messages
  • Consumer: Magento worker processing messages

RabbitMQ Configuration in env.php


'queue' => [
    'amqp' => [
        'host' => '127.0.0.1',
        'port' => '5672',
        'user' => 'guest',
        'password' => 'guest',
        'virtualhost' => '/'
    ]
]
  

Enabling Consumers

Start a specific consumer:

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

Start all consumers:

bin/magento queue:consumers:start

Run a consumer in background:

bin/magento queue:consumers:start async.operations.all &

When Should You Use RabbitMQ?

  • High-traffic stores
  • Asynchronous checkout needs
  • Enterprise & Cloud environments
  • Heavy background operations

Summary

RabbitMQ is essential for Magento 2's asynchronous architecture. It processes heavy tasks in the background, boosts performance, and supports scalable enterprise setups.