RabbitMQ 上是否有用于列出队列和交换的 API?
我查了很多资料,但一直没能找到一个好的编程方法来列出 RabbitMQ 服务器上的队列。
这很重要,因为我需要在处理完队列和交换后清理它们。我并不总是有一个好的“完成”事件可以用来触发清理,所以我想用更多的垃圾收集模型来完成它。如果我可以列出队列,我可以验证与它们相关的对象是否不应生成更多条目并清理它们。
我知道我可以使用rabbitmqctl来做到这一点,但这需要提升权限。
由于我无法找到以编程方式列出队列的方法,因此我一直在数据库中保留名称列表。这可行,但很丑。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用 Alice - http://github.com/auser/alice。它是执行rabbitmqctl命令的REST接口
You could use Alice - http://github.com/auser/alice. It is a REST interface to execute rabbitmqctl commands
2012 更新
RabbitMQ 的开发可能使问题和其他答案变得过时。提供REST API的管理插件现在是RabbitMQ的一部分。我想,该插件可能默认被禁用。
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.
如果您需要在完成后自动删除交换和队列,那么您可以根据用于 Exchange_declare 和queue_declare 的选项来完成此操作。
回到列出队列和交换器的问题,您可以使用如下工具:http://github。 com/tnc/rac
只需稍加调整,您就可以编写 PHP 脚本来获得您所需要的内容。只需检查该项目的 lib 文件夹即可。
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.