Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sending a persistent message in RabbitMQ via HTTP API

I want to send a persistent mesaage via HTTP API. Im using this command:

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

My queue is durable and deliverymode is also set to 2(Persistent), but the messages published are not durable. What change needs to be done? When I send the same via Management Console, the message is persistent but not via HTTP API.

like image 526
user2340345 Avatar asked May 06 '16 08:05

user2340345


1 Answers

delivery_mode is a properties, so you have to put it inside the "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
like image 159
Gabriele Santomaggio Avatar answered Sep 28 '22 03:09

Gabriele Santomaggio