pythonerlangrabbitmqceleryeventqueue

Consuming from queues based upon external event (event queues)


I am running into a use case where I would like to have control over how and when celery workers dequeue a task for processing from rabbitmq. Dequeuing will be synchronized with an external event that happens out of celery context, but my concern is whether celery gives me any flexibility to control dequeueing of tasks? I tried to investigate and below are a few possibilities:

I am very much inclined to continue using celery and possibly keep away from writing a custom queue processing solution on top of AMQP.


Solution

  • With remote control commands you can pause or resume message consumption from a given queue.

    celery.control.cancel_consumer('celery')
    

    the command above instructs all workers to stop consuming (dequeuing) messages from the default celery queue

    celery.control.add_consumer('celery')
    

    remote commands accept destination argument which allows to send a request to specific workers