通过HTTP API在RabbitMQ中发送持久消息

use*_*345 8 api http persistent rabbitmq

我想通过HTTP API发送持久性语言.我使用这个命令:

curl -u UN:PWD -H "content-type:application/json" -X POST -d'{"properties":{},"routing_key":"QueueName","payload":"HI","payload_encoding":"string", "deliverymode": 2}' http://url:8080/api/exchanges/%2f/amq.default/publish
Run Code Online (Sandbox Code Playgroud)

我的队列是持久的,deliverymode也设置为2(持久),但发布的消息不耐用.需要做哪些改变?当我通过管理控制台发送相同内容时,消息是持久的,但不是通过HTTP API.

Gab*_*ele 14

delivery_mode是一个属性,所以你必须把它放在"properties"as:

curl -u guest:guest -H "content-type:application/json" -X POST -d'{"properties":{"delivery_mode":2},"routing_key":"QueueName","payload":"HI","payload_encoding":"string"}' http://localhost:15672/api/exchanges/%2f/amq.default/publish
Run Code Online (Sandbox Code Playgroud)