Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RabbitMq : Is there a way to apply policy on all virtual host in cluster environment for queue mirroring?

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?

like image 501
Harish Kumar Pal Avatar asked Oct 18 '22 05:10

Harish Kumar Pal


1 Answers

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.

like image 93
Liam McLaughlin Avatar answered Nov 03 '22 06:11

Liam McLaughlin