我正在尝试在 java 中实现 Rabbitmq 教程中指定的发布/订阅模型。那里提供的示例工作正常。现在我想修改它以限制访问 Exchange 的客户端数量。
当我查看它时,我可以找到一个命令“rabbitmqctl list_bindings”来列出有界队列,这是手动输入的。有没有办法以编程方式做到这一点? 或者 我们是否有任何交换函数来返回绑定(bind)到交换器的队列数?
我找不到任何东西,请帮助我,感谢任何帮助。
最佳答案
您可以使用 management UI HTTP API,在这里你可以找到所有的API
您可以使用 API /api/exchanges/{vhost}/{exchange_name}/bindings/source
例如:
http://localhost:15672/api/exchanges/%2F/Topic_test/bindings/source
你会得到一个 json 作为结果,类似于:
[
{
"source": "Topic_test",
"vhost": "/",
"destination": "test_0",
"destination_type": "queue",
"routing_key": "",
"arguments": { },
"properties_key": "~"
},
{
"source": "Topic_test",
"vhost": "/",
"destination": "test_1",
"destination_type": "queue",
"routing_key": "",
"arguments": { },
"properties_key": "~"
},
{
"source": "Topic_test",
"vhost": "/",
"destination": "test_2",
"destination_type": "queue",
"routing_key": "",
"arguments": { },
"properties_key": "~"
}
]
关于java - 如何在 rabbitmq 中查找绑定(bind)到特定交换的队列数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38189435/