Magento – how to configure Consumer_run for async.operations.all

configurationcrontabmagento-cronsystem.log

I have enabled my custom modules for certain functionality, successfully deployed but magento2 admin portal prompts me "something went wrong" when I click my newly installed module.(the module is not working)

I headed to system.log and I found this, which are responsible to the error

> main.INFO: Consumer "async.operations.all" skipped as required
> connection "amqp" is not configured. Unknown connection name amqp []
> []

Update

I check (https://devdocs.magento.com/guides/v2.3/config-guide/mq/manage-message-queues.html)
And I m required to add external MQ, thus I followed the guide by adding line below to my magentoroot/app/etc/env.php

>   'cron_consumers_runner' => array(
>         'cron_run' => false,
>         'max_messages' => 20000,
>         'consumers' => array(
>             'async.operations.all',
>         )
>     ),

I believe i need to somehow include this 'async.operations.all' as consumers.It displayed in my bin/magento consumer:list,yet it still not working ,what did I miss here?

tried re-upgrade ,compile & deploy with sudo chmod -777 on var/www/html and clearing cache.

Update
On magentoroot/vendor/magento/module-webapi-async/etc/queue_consumer.xml

> <?xml version="1.0"?> <!-- /**  * Copyright © Magento, Inc. All rights
> reserved.  * See COPYING.txt for license details.  */
> --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>         xsi:noNamespaceSchemaLocation="urn:magento:framework-message-queue:etc/consumer.xsd">
>     <consumer name="async.operations.all" queue="async.operations.all" connection="cron_consumers_runner"
>               consumerInstance="Magento\AsynchronousOperations\Model\MassConsumer"/>
> </config>

& queue_topology.xml

> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:noNamespaceSchemaLocation="urn:magento:framework-message-queue:etc/topology.xsd">
>     <exchange name="magento" type="topic" connection="cron_consumers_runner">
>         <binding id="async.operations.all" topic="async.#" destinationType="queue" destination="async.operations.all"/>
>     </exchange> </config>

With both updated on connection with 'db' or 'cron_consumers_runner'.I do compile and clear cache, headed to the admin portal.S till the same (Attention, Something went wrong, module not working).

I head back to system.log, now there is no error anymore.

Best Answer

Check app/etc/env.php. You may be missing the connection configuration.

Add the following element to array in app/etc/env.php:

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

This is just a sample code, you have to modify it according to your requirement.

UPDATE

There are two ways to configure Message Queues in Magento2.

One is using RabbitMQ, if you are using RabbitMQ, then you need to connect to the RabbitMQ server. Above code is for that connection.

Second is using Database and cron, if you are using this setup you need configuration as mentioned at https://devdocs.magento.com/guides/v2.3/config-guide/mq/manage-message-queues.html

UPDATE 2

Check if the connection name in XML files and env.php are same.

Related Topic