RabbitMQ - List policies 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 list every policy in every virtual host.
curl
--request GET
--user john.doe:itsasecret
--url http://hostname:15671/api/policies
Or to list all of the policies in a virtual host. For the / vhost, use %2F
curl
--request GET
--user john.doe:itsasecret
--url http://hostname:15671/api/policies/vhost001
Or to list a policy in a virtual host matching a policy name.
curl
--request GET
--user john.doe:itsasecret
--url http://hostname:15671/api/policies/vhost001/foo.policy
If no matches are found, something like this should be returned.
{
'reason' => 'Not Found',
'error' => 'Object Not Found'
}
On the other hand, if the policy exists, something like this should be returned.
{
'priority' => 0,
'pattern' => '^foo.queue',
'vhost' => 'foo',
'name' => 'deadletter.foo.queue.policy',
'apply-to' => 'queues',
'definition' => {
'dead-letter-exchange' => 'deadletter.foo.queue.exchange',
'max-length-bytes' => 1048576,
'dead-letter-routing-key' => '*',
'overflow' => 'reject-publish-dlx'
}
}
Did you find this article helpful?
If so, consider buying me a coffee over at