Is there an API for listing queues and exchanges on RabbitMQ?

半世苍凉 提交于 2019-12-08 02:52:15

问题


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.


回答1:


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




回答2:


2012 update

The RabbitMQ development has probably made the question and other answers out-of-date. Management Plugin that provides REST API is now a part of RabbitMQ. The plugin might be disabled by default, thought.




回答3:


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.



来源:https://stackoverflow.com/questions/2840290/is-there-an-api-for-listing-queues-and-exchanges-on-rabbitmq

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!