Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

worker does not consume tasks after celery add_consumer is called

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

like image 932
pangyuteng Avatar asked Aug 20 '17 17:08

pangyuteng


1 Answers

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.

like image 169
Pandikunta Anand Reddy Avatar answered Sep 21 '22 07:09

Pandikunta Anand Reddy