Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the correct way to confirm a publish in celery?

I'm looking at tuning my celery/rabbitmq installation, and I found this article:

http://www.lshift.net/blog/2015/04/30/making-celery-play-nice-with-rabbitmq-and-bigwig/

It mentions doing the setting BROKER_TRANSPORT_OPTIONS = {'confirm_publish': True} if you want to guarantee message delivery (which I do). I'm having trouble finding any documentation on this setting for either rabbitmq or celery.

What is the correct way to confirm a publish in celery with rabbitmq? Where is the documentation for said feature?

like image 453
Ben Liyanage Avatar asked Mar 14 '16 19:03

Ben Liyanage


2 Answers

So to answer my own question: There is currently no documentation.

That said, I dug the source code for most of a morning and found the answer here:

https://github.com/celery/py-amqp/blob/24df1032db4a566e165f736ccb6b4a15cc94bcaa/amqp/channel.py#L1770-L1776

py-amqp is the library that celery ultimately uses (via kombu--two packages deep here folks!). py-amqp reads that setting and has a wait when the confirm_publish option is set. This effectively makes a queuing process synchronous.

like image 92
Ben Liyanage Avatar answered Oct 16 '22 10:10

Ben Liyanage


confirm_publish option is used by py-amqp library https://github.com/celery/py-amqp It forces publish to block connection until confirmation is received from RabbitMQ. RabbitMQ confirmations are described here: https://www.rabbitmq.com/confirms.html

like image 30
Daniil Fedotov Avatar answered Oct 16 '22 10:10

Daniil Fedotov