ha-all policy

483 views
Skip to first unread message

Kris Reese

unread,
Sep 16, 2014, 3:17:56 PM9/16/14
to rabbitm...@googlegroups.com
In the documentation discussing Highly Available Queues (http://www.rabbitmq.com/ha.html), the first sentence states:
"By default, queues within a RabbitMQ cluster are located on a single node (the node on which they were first declared). This is in contrast to exchanges and bindings, which can always be considered to be on all nodes."

Further down, in the example provided for setting the policy to mirror queues to all nodes in the cluster, I noticed the example command does not use the "--apply-to queues" switch.  Let's say, this was used to set a policy to mirror all queues:

rabbitmqctl set_policy ha-all ".*" '{"ha-mode":"all"}'

While I understand that setting up a cluster syncs any users, virtual hosts, queues, exchanges, etc that are created across the cluster, where "exchanges and bindings can always be considered to be on all nodes", I was wondering if this policy would have any adverse effects if it were "--apply-to queues" only, since it would not then also apply to exchanges.


Thank you

Michael Klishin

unread,
Sep 16, 2014, 3:22:50 PM9/16/14
to rabbitm...@googlegroups.com, Kris Reese
 On 16 September 2014 at 23:18:03, Kris Reese (ktr...@gmail.com) wrote:
> Further down, in the example provided for setting the policy
> to mirror queues to all nodes in the cluster, I noticed the example
> command does not use the "--apply-to queues" switch. Let's say,
> this was used to set a policy to mirror all queues:
>
> rabbitmqctl set_policy ha-all ".*" '{"ha-mode":"all"}'
>
> While I understand that setting up a cluster syncs any users,
> virtual hosts, queues, exchanges, etc that are created across
> the cluster, where "exchanges and bindings can always be considered
> to be on all nodes", I was wondering if this policy would have any
> adverse effects if it were "--apply-to queues" only, since it
> would not then also apply to exchanges.

Exchanges do not actually exist. They are just routing table names. Routing table
rows are bindings. The table is automatically distributed between all cluster nodes.
Same goes for queue parameters, vhosts, users, and permissions.

Queue *contents* by default are not replicated. --apply-to "queues" is needed
when a policy may affect exchanges semantically.

A policy that adds "ha-mode" won't affect exchanges, so don't worry about it.
But if you want to explicitly use --apply-to "queues", nothing wrong with that.
--
MK

Staff Software Engineer, Pivotal/RabbitMQ

Kris Reese

unread,
Sep 17, 2014, 5:43:21 PM9/17/14
to rabbitm...@googlegroups.com, ktr...@gmail.com
ok - thanks for the explanation.  I was curious because I do notice (using version RabbitMQ 3.3.3), that the ha-all policy name is being applied to the exchanges (since I am pattern matching '.*', despite having defined "ha-mode".  Sounds like the ha-mode definition only applies to queues.

I guess there's no logic in the code to not apply policy definitions to things which do not affect them.

Simon MacMullen

unread,
Sep 18, 2014, 6:06:07 AM9/18/14
to Kris Reese, rabbitm...@googlegroups.com
On 17/09/14 22:43, Kris Reese wrote:
> I guess there's no logic in the code to not apply policy definitions to
> things which do not affect them.

No; in the general case you could have a policy which specified both
queue-ish things and exchange-ish things, so I *think* it's clearer to
show policies always matching, even if they don't do anything.

One day I would like to have an "effective policy" field which shows
which parts of the policy apply and how they interact with arguments (if
any). One day.

Cheers, Simon
Reply all
Reply to author
Forward
0 new messages