使用 http api 发布到默认的 rabbitmq 交换 [英] Publishing to the default rabbitmq exchange using the http api
问题描述
所以我使用rabbitmqs http api 在rabbit 中做一些非常基本的动作.它在大多数情况下都很好用,但我在弄清楚如何使用它向默认的 rabbitmq 交换发布消息时遇到了问题.此交换始终存在,无法删除,并且绑定到每个队列,其路由键等于队列名称.
我的问题是这个队列没有名字,或者更确切地说,它的名字是一个空字符串".我必须用来通过 HTTP api 发布此消息的 URL 包含交换的名称.
So I am using rabbitmqs http api to do some very basic actions in rabbit. It works great in most situations but I am having an issue figuring out how to use it to publish a message to the default rabbitmq exchange. This exchange is always present, cannot be deleted and has a binding to every queue with a routing key equal to the queue name.
My problem is that this queue does not have a name, or rather, it's name is an empty string "". And the URL I have to use to publish this message with the HTTP api includes the name of the exchange.
http://localhost:15672/api/exchanges/vhost/name/publish (Source: http://hg.rabbitmq.com/rabbitmq-management/raw-file/rabbitmq_v3_3_4/priv/www/api/index.html)
The same article mentions that in order to use the default vhost which has a name of "/", you must use %2f in place of the vhost name. This makes me think there should be a similar way to represent the deafault exchange in the url.
I tried a few different things and none of them worked:
/api/exchanges/vhost//publish
/api/exchanges/vhost/""/publish
/api/exchanges/vhost/''/publish
/api/exchanges/vhost/ /publish
/api/exchanges/vhost/%00/publish
I'm sure I can't be the only person that has run into this issue. any help would be much appreciated.
thanks, Tom
This is the way to publish a message to amq.default
:
http://localhost:15672/api/exchanges/%2f/amq.default/publish
with this body
{"properties":{},
"routing_key":"queue_test",
"payload":"message test ",
"payload_encoding":"string"}
routing_key
is the queue where you will publish the message.
Following an example using a chrome plug-in:
这篇关于使用 http api 发布到默认的 rabbitmq 交换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!