Deleting all pending tasks in celery / rabbitmq
For celery 3.0+:
$ celery purge
To purge a specific queue:
$ celery -Q queue_name purge
For Celery 2.x and 3.x:
When using worker with -Q parameter to define queues, for example
celery worker -Q queue1,queue2,queue3
then celery purge
will not work, because you cannot pass the queue params to it. It will only delete the default queue.
The solution is to start your workers with --purge
parameter like this:
celery worker -Q queue1,queue2,queue3 --purge
This will however run the worker.
Other option is to use the amqp subcommand of celery
celery amqp queue.delete queue1
celery amqp queue.delete queue2
celery amqp queue.delete queue3
From the docs:
$ celery -A proj purge
or
from proj.celery import app
app.control.purge()
(EDIT: Updated with current method.)