You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

activemq-cli是否支持发送JSON格式队列消息?求示例

解答

activemq-cli支持发送JSON格式消息,你遇到的报错是因为工具默认将消息内容当作XML解析,而JSON的起始字符{不符合XML的语法规则(XML要求开头是声明或根元素),因此触发了XML解析器的"Content is not allowed in prolog"错误。

解决步骤及示例

  1. 准备合法的JSON消息文件(比如sample.json):
{
  "messageId": "1001",
  "payload": {
    "user": "test_user",
    "action": "submit_order",
    "timestamp": "2024-05-20T14:30:00Z"
  }
}
  1. 发送时指定Content-Type为JSON:
    使用--content-type参数明确告诉工具这是JSON格式的消息,命令如下:
send-message --file sample.json --queue YOUR_QUEUE_NAME --content-type application/json

验证接收

如果需要验证消息是否成功发送,可使用接收命令并指定对应Content-Type:

receive-message --queue YOUR_QUEUE_NAME --content-type application/json

内容的提问来源于stack exchange,提问作者Jie Liu

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.13 21:32:02