I'm using Magento 2.3.4 with RabbitMQ configured in the env.php to process my message queues, I start consumer using:

bin/magento queue:consumers:start ConsumerName --max-messages 1

But the consumer keeps listening forever, never exits.

It seems to be a native issue in Magento, how could I solve it?


I had to force the setting to be 0 by adding the below to env.php:

'queue' => [
    'consumers_wait_for_messages' => 0

If you look at this file: vendor/magento/framework-message-queue/CallbackInvoker.php

You will see that Magento 2 actually makes the default for this setting 1 (contrary to the documentation)

 * Checks if consumers should wait for message from the queue
 * @return bool
private function isWaitingNextMessage(): bool
    return $this->deploymentConfig->get('queue/consumers_wait_for_messages', 1) === 1;

After doing that, my other cron processes started running again and I no longer saw the parent cron job as "stuck"

Full article here.

Reference here.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.