如何使用Web插件将JSON负载发送到RabbitMQ? [英] How to send JSON payload to RabbitMQ using the web plugin?
问题描述
我有一个 RabbitMQ 3.4.2实例,其中安装了Web管理插件.
I have a RabbitMQ 3.4.2 instance with a web management plugin installed.
当我使用Python的 kombu 队列程序包将消息{'operationId': 194}
推送到队列时,该消息在另一端作为字典阅读.
When I push to the message {'operationId': 194}
to the queue using Python's kombu queue package, the message is read on the other end as a dictionary.
但是,当我使用Web控制台发送消息时:
However, when I send the message using the web console:
我在接收端收到以下错误:
I get the following error on the receiving end:
operation_id = payload['operationId']
TypeError: string indices must be integers
我尝试添加content-type
标头和属性,但没有成功.
I have tried adding a content-type
header and property, with no success.
由于阅读器代码相同,这意味着Web发送方不会将发送的消息标记为JSON/字典有效负载,因此在另一端将其读取为字符串.
Since the reader code is the same, it means that the web sender does not mark the sent message as a JSON / dictionary payload, and therefore it is read as a string on the other end.
是否知道如何使用RabbitMQ Web控制台将消息标记为JSON消息?
推荐答案
我必须使用content_type
而不是content-type
(下划线而不是连字符).
I had to use content_type
instead of content-type
(an underscore instead of a hyphen).
这是一个非常可疑的设计决策,因为每个人都知道的标准是 content-type
.
This is a pretty questionable design decision, because the standard everybody knows is content-type
.
这篇关于如何使用Web插件将JSON负载发送到RabbitMQ?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!