3

I am using Django Celery with a RabbitMQ backend, all hosted on Heroku.

From the Celery docs, it is clear that Celery is designed to create new queues for tasks. My problem is, when I go into my RabbitMQ console, I see that only the default queue has any consumers (celeryd instances) hooked up to it. The result is, all the tasks on the non-default queues never run.

Since the Celery docs explicitly state that Celery is supposed to create many queues, I feel like I must be missing something very basic here with my config. Nonetheless, I can't get my consumers to 'jump around' and look for non empty queues -- they just stay on the empty default queue.

Any ideas on how to solve this problem?

Thanks!

4

1 回答 1

1

我和你有同样的问题,但是深入研究文档我认为即使队列是自动创建的,你仍然需要明确告诉你的芹菜工人从新创建的队列中开始消费。

根据文档,工作人员明确绑定到一个或多个队列。也就是说,如果您在启动 worker 时没有指定 -Q 参数,它将被绑定到“默认”队列,另一方面,如果您为 -Q 参数提供值,那么它将被绑定到您提供的那些特定队列。我理解这意味着您不能将工作人员绑定到“未定义”队列(或稍后将创建的队列)。

来自文档: http ://docs.celeryproject.org/en/latest/userguide/workers.html#queues

似乎要让您的工作人员开始从新创建的队列中消费,您可以使用 add_consumer() 方法向他们发送一条消息(在运行时)这样做。

于 2013-07-23T00:19:07.930 回答