RabbitMQ - Create a policy using the rabbitmqctl command set_policy command

by
Jeremy Canfield |
Updated: February 23 2022
| RabbitMQ articles
The rabbitmqctl set_policy command can be used to create a policy. In this example, a policy named policy001 is created in virtual host vhost001 to set the max length to 100 messages. The wildcard applies the policy to all queues.
rabbitmqctl set_policy
--vhost vhost001
--priority 0
--apply-to queues
policy001
".*"
'{
"max-length": 10,
"overflow": "drop-head",
"dead-letter-exchange": "deadletter.exchange",
"dead-letter-routing-key": "dlrk"
}'
If the policy is successfully created, something like this should be returned.
Setting policy "policy001" for pattern ".*" to "{"max-length": 100, "overflow": "drop-head", "dead-letter-exchange": "deadletter.exchange", "dead-letter-routing-key": "dlrk" }" with priority "0" for vhost "vhost001" ...
Did you find this article helpful?
If so, consider buying me a coffee over at