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 asynchronouslyto Yes.

Testing the message queue

To test message sending from Commerce to RabbitMQ:

  1. Log in to the RabbitMQ web console in AWS to monitor queues.

  2. In the Admin, create a product.

  3. Create an Inventory source.

  4. Enable Stores > Configuration > Catalog > Inventory > Admin bulk operations > Run asynchronously.

  5. Go to Catalog > Products. From the grid, select the product created above and click Assign Inventory Source.

  6. Click Save & Close to complete the process.

    You should now see messages appear in the RabbitMQ web console.

  7. 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.

recommendation-more-help