Can I review and delete Celery / RabbitMQ tasks in

2019-07-28 18:51发布

问题:

I am running Django + Celery + RabbitMQ. After modifying some task names I started getting "unregistered task" KeyErrors, even after removing tasks with this key from the Periodic tasks table in Django Celery Beat and restarting the Celery worker.

It turns out Celery / RabbitMQ tasks are persistent. I eventually resolved the issue by reimplementing the legacy tasks as dummy methods.

In future, I'd prefer not to purge the queue, restart the worker or reimplement legacy methods. Instead I'd like to inspect the queue and individually delete any legacy tasks. Is this possible? (Preferably in the context of the Django admin interface.)

回答1:

Celery inspect may help

To view active queues:

celery -A proj inspect active_queues

To terminate a process:

celery -A proj control invoke process_id

To see all availble inspect options:

celery inspect --help