RabbitMQ - Create Queue using the REST API
by
Jeremy Canfield |
Updated: February 23 2022
| RabbitMQ articles
This assumes you have created a RabbitMQ user with the administrator tag.
Refer to the RabbitMQ REST API documentation.
The curl command with the --user option can be used to make an API connection to RabbitMQ. In this example, John Doe will make a connection to the RabbitMQ server listening on port 15671 and then create a queue named foo.queue.
curl
--request PUT
--user john.doe:itsasecret
--url http://hostname:15671/api/queues/vhost001/foo.queue
--header 'content-type: application/json'
--data '{ "auto_delete": false, "durable": true }'
--write-out "%{http_code}"
For the / vhost, use %2F
curl
--request PUT
--user john.doe:itsasecret
--url http://hostname:15671/api/queues/%2f/foo.queue
--header 'content-type: application/json'
--data '{ "auto_delete": false, "durable": true }'
--write-out "%{http_code}"
And here is an example of how you would include arguments, such as x-queue-type and x-queue-mode.
curl
--request PUT
--user john.doe:itsasecret
--url http://hostname:15671/api/queues/vhost001/foo.queue
--header 'content-type: application/json'
--data '{ "auto_delete": false, "durable": true, "arguments": { "x-queue-type": "classic", "x-queue-mode": "lazy" } }'
--write-out "%{http_code}"
No output will be returned, regardless if the queue is or is not created. For this reason, the -w or --write-out option is included to get the return code of the curl command.
Did you find this article helpful?
If so, consider buying me a coffee over at