I would like to leverage Celery (with RabbitMQ as backend MQ) to execute tasks of varying flavors via different Queues. One requirement is that consumption (by the workers) from a particular Queue should have the capability to be paused and resumed.
Celery, seems to have this capability via calling add_consumer
and cancel_consumer
. While I was able to cancel the consumption of tasks from a queue for a particular worker, I cannot get the worker to resume consumption by calling add_consumer
. The code to reproduce this issue is provided here. My guess is likely I'm missing some sort of a parameter to be provided either in the celeryconfig
or via the arguments when starting the workers?
Would be great to get some fresh pairs of eyes on this. There is not much discussion on Stackoverflow regarding add_consumer nor in Github. So I'm hoping there's some experts here willing to share their thoughts/experience.
--
I am running the below:
Windows OS, RabbitMQ 3.5.6, Erlang 18.1, Python 3.3.5, celery 3.1.15
To resume from queue, you need to specify queue name as well as target workers. Here is how to do it.
app.control.add_consumer(queue='high', destination=['celery@asus'])
Here is add_consumer signature
def add_consumer(state, queue, exchange=None, exchange_type=None,
routing_key=None, **options):
In your case, you are calling with
app.control.add_consumer('high', destination=['celery@high1woka'])
So high
is getting passed to state and queue is empty. So it is not able to resume.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With