Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

celery+rabbitmq empty queue

I am using celery+rabbitmq. I can't find convenient way to clear queue in celery+rabbitmq. I do it with remove and create vhost.

rabbitmqctl delete_vhost <vhostpath>
rabbitmqctl  add_vhost <vhostpath>

Is it prefer way to clear some celery queue ?

like image 504
Evg Avatar asked Dec 04 '22 20:12

Evg


1 Answers

I'm not quite sure how celery works, but I suspect you want to purge a RabbitMQ queue (you're currently simulating this by deleting the queues and having celery re-create them).

You could install RabbitMQ's Management Plugin. Its WebUI will allow you to purge the required queue. This should also tell you which queue you're aiming for, so you wouldn't need to delete everything.

Once you know which queue it is, you could purge it programatically. For instance, using py-amqplib, you would do something like:

from amqplib import client_0_8 as amqp

conn = amqp.Connection(host="localhost:5672", userid="guest", password="guest", virtual_host="/", insist=False)
conn = conn.channel()
conn.queue_purge("the-target-queue")

There's probably a better way to do it, though.

like image 60
scvalex Avatar answered Mar 15 '23 06:03

scvalex