How Commerce uses the AWS MQ service
The 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 asynchronously
to Yes.
Testing the message queue
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.
-
Start the
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.