In RabbitMQ,
If I want to mirror queue in cluster environment I use below command :
rabbitmqctl set_policy ha-all "" '{"ha-mode":"all","ha-sync-mode":"automatic"}'
This command will apply policy to all queues of virtual host "\"
.
If I have to apply the policy for specific virtual host say "foo" I use:
rabbitmqctl set_policy -p "foo" ha-all "" '{"ha-mode":"all","ha-sync-mode":"automatic"}'
Question :
Is there a way to apply policy on all virtual host in cluster environment for queue mirroring?
If you are running on a *nix environment, the following should work
rabbitmqctl list_vhosts | while read line ; do rabbitmqctl set_policy -p "$line" ha-all "" '{"ha-mode":"all","ha-sync-mode":"automatic"}'; done
This will pipe each line of the output into your rabbitmqctrl command.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With