Long running task Pika/RabbitMQ

948 views
Skip to first unread message

Yasmina Bouzbiba

unread,
Jun 1, 2022, 11:42:29 AM6/1/22
to Pika
Hello,

I have a code based on this example https://github.com/pika/pika/blob/0.12.0/examples/basic_consumer_threaded.py which receive data from queues and process them on another thread (as the process is really long). But even if I am using this example from pika I'm still getting an error :

1654011396.901431 - pika.channel - WARNING - channel._on_close_from_broker - Received remote Channel.Close (406): 'PRECONDITION_FAILED - delivery acknowledgement on channel 1 timed out. Timeout value used: 1800000 ms. This timeout value can be configured, see consumers doc guide to learn more' on <Channel number=1 OPEN conn=<SelectConnection OPEN transport=<pika.adapters.utils.io_services_utils._AsyncPlaintextTransport object at 0x7faf9b547670> params= ConnectionParameters host=* port=* virtual_host=/ ssl=False>>>

Traceback (most recent call last): File "rabbit.py", line 91, in channel.start_consuming() File "/opt/app/project/venv/lib/python3.8/site-packages/pika/adapters/blocking_connection.py", line 1865, in start_consuming self._process_data_events(time_limit=None) File "/opt/app/project/venv/lib/python3.8/site-packages/pika/adapters/blocking_connection.py", line 2031, in _process_data_events raise self._closing_reason # pylint: disable=E0702 pika.exceptions.ChannelClosedByBroker: (406, 'PRECONDITION_FAILED - delivery acknowledgement on channel 1 timed out. Timeout value used: 1800000 ms. This timeout value can be configured, see consumers doc guide to learn more')

My code :

Capture d’écran 2022-06-01 à 17.40.07.pngCapture d’écran 2022-06-01 à 17.40.36.png

What can I do to avoid this error without changing the configuration of rabbitmq ?

Thank you.




Luke Bakken

unread,
Jun 2, 2022, 9:59:15 AM6/2/22
to Pika
Hello,

RabbitMQ will close a channel if your consumer does not acknowledge a message within 30 minutes. Rather than changing this setting, you could use another queue as an "in-progress work" queue. Here's the general idea:

* Consume the message from RabbitMQ
* Publish the message to the worker's "in-progress queue". Be sure to use publisher confirmations.
* Acknowledge the message
* Do your work
* Consume and acknowledge from the "in-progress queue". There should only be one message on this queue and you can use auto-ack for this.

If your worker crashes, the message will still be available on its "in-progress queue".

Thanks,
Luke

On Wednesday, June 1, 2022 at 8:42:29 AM UTC-7 bouzbiba...@gmail.com wrote:
Hello,

I have a code based on this example https://github.com/pika/pika/blob/0.12.0/examples/basic_consumer_threaded.py which receive data from queues and process them on another thread (as the process is really long). But even if I am using this example from pika I'm still getting an error :

1654011396.901431 - pika.channel - WARNING - channel._on_close_from_broker - Received remote Channel.Close (406): 'PRECONDITION_FAILED - delivery acknowledgement on channel 1 timed out. Timeout value used: 1800000 ms. This timeout value can be configured, see consumers doc guide to learn more' on <Channel number=1 OPEN conn=<SelectConnection OPEN transport=<pika.adapters.utils.io_services_utils._AsyncPlaintextTransport object at 0x7faf9b547670> params= ConnectionParameters host=* port=* virtual_host=/ ssl=False>>> 

What can I do to avoid this error without changing the configuration of rabbitmq ?

Reply all
Reply to author
Forward
Message has been deleted
0 new messages