RabbitMQ C# API: How to check if a binding exists?

梦想与她 提交于 2019-12-10 17:44:14

问题


Using the RabbitMQ C# API, how would I check to see if a binding exists from a given queue to a given exchange?

A lot of RabbitMQ calls are idempotent, so some people may say that the check is unnecessary for those cases, but I think they would be useful in testing.


回答1:


You could use their REST API to call and see if the binding exists.

You have a local copy of the API reference at: your_server_name:15672/api/ or you can find it at their online docs

You can make a GET call to either:

  • /api/exchanges/vhost
  • /name/bindings/destination

with the appropriate substitutions in there for vhost or name.

Or you could just call:

  • /api/bindings

to get all of them.

From there, you'll need to parse the JSON object that is returned.

Note, you will likely need to authenticate but their examples show how to do so.



来源:https://stackoverflow.com/questions/26046053/rabbitmq-c-sharp-api-how-to-check-if-a-binding-exists

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