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

时间:2016-05-06 08:13:48

标签: api http rabbitmq persistent

我想通过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

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

1 个答案:

答案 0 :(得分:12)

delivery_mode是一个属性,因此您必须将其放在"properties"中:

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