5

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?

Isabel Inc
  • 1,871
  • 2
  • 21
  • 28

1 Answers1

3

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.

Liam McLaughlin
  • 496
  • 5
  • 7