通过 HTTP 在 RabbitMQ 中发送持久消息 API
Sending a persistent message in RabbitMQ via HTTP API
我想通过 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(Persistent),但是发布的消息不是持久化的。需要做什么改变?
当我通过管理控制台发送相同的消息时,消息是持久的,但不是通过 HTTP API.
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
我想通过 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(Persistent),但是发布的消息不是持久化的。需要做什么改变? 当我通过管理控制台发送相同的消息时,消息是持久的,但不是通过 HTTP API.
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