Federation Reference
This page provides a reference on all the fields you can set when defining federation parameters, and describes how you can monitor federation links.
Configuration reference
Policies
A policy can apply an upstream set (including the implicitly-defined upstream set “all”) or a single upstream to a set of exchanges and / or queues.
To apply all upstreams:
rabbitmqctl set_policy federate-me '^amq\.' '{"federation-upstream-set":"all"}'
To apply a named set of upstreams:
rabbitmqctl set_policy federate-me '^amq\.' '{"federation-upstream-set":"my-set"}'
To apply a single upstream:
rabbitmqctl set_policy federate-me '^amq\.' '{"federation-upstream":"my-upstream"}'
Note that you cannot use the federation-upstream and federation-upstream-set keys together in a policy. For more detail on policies, see the policy documentation.
Upstreams
A federation-upstream parameter specifies how to connect to a broker. It takes the form:
rabbitmqctl set_parameter federation-upstream name 'json-object'
The json-object can contain the following keys:
Applying to federated exchanges and federated queues
Note that this field can either be a string, or a list of strings. If more than one string is provided, the federation plugin will randomly pick one URI from the list. This can be used to connect to an upstream cluster and ensure the link will eventually find another node in the event that one fails. It’s probably not a great idea to use multiple URIs that do not point to the same cluster.
To connect to multiple URIs simultaneously use multiple upstreams.
If set to on-publish, messages are acknowledged to the upstream broker after they have been published downstream. This handles network errors without losing messages, but may lose messages in the event of broker failures.
If set to no-ack, message acknowledgements are not used. This is the fastest option, but may lose messages in the event of network or broker failures.
Applying to federated exchanges only
This setting controls how long the upstream queue will last before it is eligible for deletion if the connection is lost.
This value is used to set the “x-expires” argument for the upstream queue.
This value is used to set the “x-message-ttl” argument for the upstream queue.
Applying to federated queues only
Upstream sets
Each upstream-set list is a set of upstreams.
rabbitmqctl set_parameter federation-upstream-set name '[json-object, json-object, ...]'
The keys of the JSON objects can be:
In addition, any of the properties from an upstream can be overridden in an upstream set.
There is an implicitly-defined upstream set, all, which contains all upstreams.
cluster name
The federation plugin uses the cluster name defined within the server to identify itself to other nodes in the federation graph. (The default is constructed from the Erlang node and the fully-qualified domain name of the first node to form the cluster.)
This can be changed with rabbitmqctl set_cluster_name or via the management plugin.
It is important to specify this explicitly if your DNS will not give machines distinct names.
Example:
rabbitmqctl set_cluster_name '"my-name"'
Link status reporting
Each combination of federated exchange or queue and upstream needs a link to run. This is the process that retrieves messages from upstream and republishes them downstream. You can monitor the status of federation links using rabbitmqctl and the management plugin.
Using rabbitmqctl
Invoke:
rabbitmqctl eval 'rabbit_federation_status:status().'
This will return a list of federation links running on the node you are connecting to (i.e. not cluster-wide). It contains the following keys:
- starting
- {running, LocalConnectionName}
- {shutdown, Error}
Example:
# rabbitmqctl eval 'rabbit_federation_status:status().'
[[{type,<<"exchange">>},
{name,<<"my-exchange">>},
{vhost,<<"/">>},
{connection,<<"upstream-server">>},
{upstream_name,<<"my-upstream-x">>},
{status,{running,<<"<rabbit@<example>.1.281.0>">>}},
{timestamp,{{2012,3,1},{12,3,28}}}]]
...done.
Using the management plugin
Install the rabbitmq_federation_management plugin. You will now be able to see all federation links in the cluster by clicking on Admin > Federation Status, or making an HTTP request to GET /api/federation-links.