As of Commerce 2.4.3, Amazon Message Queue (MQ) is available as a cloud-ready replacement for on-premises message queue instances.
To create a message queue on AWS, see Setting up Amazon MQ in the AWS documentation.
In order to connect to the AWS MQ service, configure the
queue.amqp object in the
AWS Message Queue requires a SSL/TLS connection.
'queue' => [ 'amqp' => [ 'host' => '[host]', //example: c-bf4kk1c5-5gcc-4b43-9b9e-8f5b54d234.mq.us-west-3.amazonaws.com 'port' => 5671, 'user' => 'yourusername', 'password' => 'yourpassword', 'virtualhost' => '/', // AWS fields to add 'ssl' => 'true' ] ],
host—The url for the AMQP endpoint; available by clicking the broker name in AWS (remove “https://” and the trailing port number)
user—The username value entered when creating the AWS MQ broker
password—The password value entered when creating the AWS MQ broker
Amazon MQ supports TLS connections only. Peer verification is not supported.
After editing the
env.php file, run the following command to finish the setup:
async.operations.all message queue consumer uses the AMQP connection.
This consumer routes any topic name prefixed with
async through the AWS MQ connection.
For example, in
InventoryCatalog there are:
async.V1.inventory.bulk-product-source-assign.POST async.V1.inventory.bulk-product-source-unassign.POST async.V1.inventory.bulk-product-source-transfer.POST
The default configuration for
InventoryCatalog does not publish messages to RabbitMQ; the default behavior is to perform the action in the same user thread. To tell
InventoryCatalog to publish messages, enable
cataloginventory/bulk_operations/async. From the admin, go to Stores > Configuration > Catalog > Inventory > Admin bulk operations and set
Run asynchronouslyto Yes.
To test message sending from Commerce to RabbitMQ:
Log in to the RabbitMQ web console in AWS to monitor queues.
In the Admin, create a product.
Create an Inventory source.
Enable Stores > Configuration > Catalog > Inventory > Admin bulk operations > Run asynchronously.
Go to Catalog > Products. From the grid, select the product created above and click Assign Inventory Source.
Click Save & Close to complete the process.
You should now see messages appear in the RabbitMQ web console.
async.operations.all message queue consumer.
bin/magento queue:consumers:start async.operations.all
You should now see the queued message get processed in the RabbitMQ web console.
Verify that inventory sources have changed on the product in the Admin.