views:

116

answers:

2

I've looked quite a bit, but I haven't been able to find a good programmatic way to list the queues on a RabbitMQ server.

This is important because I need to clean up my queues and exchanges when I'm done with them. I don't always have a good "done" event that can be used to trigger a cleanup, so I'd like to do it with more of a garbage collection model. If I can list the queues, I can verify that the objects that they're related to shouldn't be producing more entries and clean them up.

I know I can use rabbitmqctl to do it, but that needs elevated privileges.

Since I haven't been able to find a way to list the queues programmatically, I've been keeping a list of names in the database. That works, but it's ugly.

A: 

If what you need is to auto delete the exchange and the queues when you are done, then you can accomplish that based on the options that you use for exchange_declare and queue_declare.

Coming back to your question of listing queues and exchanges, you can use a tool like this one: http://github.com/tnc/rac

With a little tweaking you can write a PHP script to get what you need. Just check under the lib folder of that project.

old_sound
I've looked over those options and they don't seem to support auto-cleanup unless you keep a connection open the whole time you're using the queue. I need to be able to use the queue from a farm of webservers where requests might bounce between servers. Likewise, I need to read messages after the writing process has completed, but I have no guarantee that I'll ever read all the messages and need to clean up regardless.Looking at rac, it looks like there really is no API for this and you have to use an Erlang interface to get at the information.
edebill
+3  A: 

You could use Alice - http://github.com/auser/alice. It is a REST interface to execute rabbitmqctl commands

andy318