使用HTTP API发布到默认RabbitMQ交换

编程入门 行业动态 更新时间:2024-10-28 18:34:46
本文介绍了使用HTTP API发布到默认RabbitMQ交换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

因此,我正在使用rabbitmqs http api在rabbit中执行一些非常基本的操作.它在大多数情况下都很好用,但是我在弄清楚如何使用它将消息发布到默认的rabbitmq交换时遇到了问题.此交换始终存在,不能删除,并且具有与每个队列名称相同的路由密钥的每个队列绑定.

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.

我的问题是此队列没有名称,或者,它的名称是空字符串".我必须使用URL来通过HTTP api发布此消息,其中包括交换的名称.

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.

localhost:15672/api/exchanges/vhost/name/publish (来源: hg. rabbitmq/rabbitmq-management/raw-file/rabbitmq_v3_3_4/priv/www/api/index.html )

同一篇文章提到,要使用名称为"/"的默认虚拟主机,必须使用%2f代替虚拟主机名.这使我认为应该以类似的方式在URL中表示默认交换.

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.

谢谢, 汤姆

推荐答案

这是将消息发布到amq.default的方法:

This is the way to publish a message to amq.default:

localhost:15672/api/exchanges/%2f/amq.default/publish

有这个身体

{"properties":{}, "routing_key":"queue_test", "payload":"message test ", "payload_encoding":"string"}

routing_key是您将在其中发布消息的队列.

routing_key is the queue where you will publish the message.

以下是使用chrome插件的示例:

Following an example using a chrome plug-in:

更多推荐

使用HTTP API发布到默认RabbitMQ交换

本文发布于:2023-10-11 14:01:13,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1481902.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:HTTP   API   RabbitMQ

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!