Messages are stuck in the Unacked state

Edit on GitHub

Description

Messages are getting stuck or do not get consumed from RabbitMQ queues. They are not getting moved to the error queue and there is no visible error in CloudWatch log groups. Instead, the messages are stuck in the Ready queue and are moved to the Unacked state and not consumed and moved back, or are stuck in the Unacked state.

Cause

This is most often caused by the consumption process not being able to successfully finish to do OOM error.

Solution

Unfortunately, this is tricky to diagnose in a PaaS environment as you may lack debugging tools. However, you can try to reduce the chunk size. For this, adjust the following configuration in the default_config.php file of your project:

$config[EventConstants::EVENT_CHUNK]

Try to reduce it drastically—for example, reduce to 100 and redeploy. Then, you can move back the stuck messages from Unacked to the ready state so that the consumers can try to consume them again by force closing the connections as the following example shows.

Force Close RabbitMQ Connections

Once the queue worker process runs, the messages are attempted to be consumed again.

If the messages are still not consumable, try to reproduce this behavior locally by dumping your database and publishing the messages in your local development environment as explained in HowTo: Do better deployments.

If the messages are consumed in your local environment without a problem, get in touch with our support and include the information that you have tested the consumption locally.