why message queue consumer never exiting when --max-messages specified?
-
13-04-2021 - |
Question
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?
La solution
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.
Licencié sous: CC-BY-SA avec attribution
Non affilié à magento.stackexchange