[rabbitmq-discuss] Federation help

James Aimonetti james at 2600hz.com
Sat Nov 26 18:27:04 GMT 2011

Hash: SHA1

Hey all,

Wanting to add federation to existing brokers but not sure I'm
understanding the semantics involved.

Let's say I have three exchanges, {events, topic}, {control, direct},
and {config, topic}, all three of which are on both brokers (in
different datacenters).

My current rabbit.config looks like:

  ,[{exchanges, [
		 [{exchange, "config"}
		  ,{type, "topic"}
		  ,{upstream_set, "config_exchanges"}
		 ,[{exchange, "control"}
		  ,{type, "direct"}
		  ,{upstream_set, "control_exchanges"}
		 ,[{exchange, "events"}
		  ,{type, "topic"}
		  ,{upstream_set, "events_exchanges"}
         ,{upstream_sets, [{"control_exchanges", [[{connection,
                          ,{"events_exchanges", [[{connection, "broker2"}]]}
		          ,{"config_exchanges", [[{connection, "broker2"}]]}
    ,{connections, [{"broker2", [{host, "broker2.example.com"}]}]}
    ,{local_nodename, "broker1.example.com"}
 ...more config

I have an almost identical config on brokers 1 and 2 (with hostnames
obviously adapted). Both startup fine (*sidenote: I had to set
ERL_LIBS=/path/to/rabbit/plugins to get the federation plugin to work -
the VM couldn't find the amqp_connection module, even after enabling the
amqp_client plugin). I see both brokers communicating about the
exchanges - lines similar to:

=INFO REPORT==== 26-Nov-2011::18:04:01 ===
Federation exchange 'control' in vhost '/' connected to

I start my application (in a separate VM) connecting to broker1, try to
declare my exchanges as part of my app's init, and get errors like:

                      <<"PRECONDITION_FAILED - cannot redeclare exchange
'control' in vhost '/' with different type, durable, internal or
autodelete value">>}},

So I explicitly set type, durable, internal, and autodelete to 'false'
in my federation configs, but to no avail. I should note I have no
durable exchanges or queues in this system; everything is ephemeral.
Neither broker is clustered with any others.

I do see errors when I restart a broker similar to:

=ERROR REPORT==== 26-Nov-2011::18:04:00 ===
connection <0.2064.0>, channel 2 - error:
            "no exchange 'federation: control -> broker2.example.com B'
in vhost '/'",

My understanding (which may be bass-ackwards) is that by setting up the
'control' exchange to federate with broker2, broker1 will receive
payloads from broker2's 'control' exchange and route them to any queues
bound to broker1's 'control' exchange, and that my application code
remains relatively unchanged to take advantage of that. The converse
too: since broker2 is connecting to broker1, any payloads my apps on
broker1 send to the 'control' exchange will be relayed to broker2.

Thanks for any guidance; sorry for the wall of text.


PS: My broker output when starting up:

Activating RabbitMQ plugins ...
2 plugins activated:
* amqp_client-2.7.0
* rabbitmq_federation-2.7.0

+---+   +---+
|   |   |   |
|   |   |   |
|   |   |   |
|   +---+   +-------+
|                   |
| RabbitMQ  +---+   |
|           |   |   |
|   v2.7.0  +---+   |
|                   |
AMQP 0-9-1 / 0-9 / 0-8
Copyright (C) 2007-2011 VMware, Inc.
Licensed under the MPL.  See http://www.rabbitmq.com/

node           : rabbit at broker1.example.com
app descriptor :
home dir       : /var/lib/rabbitmq
config file(s) : /etc/rabbitmq/rabbitmq.config
cookie hash    : SgcmwZTTAvznNXVC3eUfkQ==
log            : /var/log/rabbitmq/rabbit at broker1.example.com.log
sasl log       : /var/log/rabbitmq/rabbit at broker1.example.com-sasl.log
database dir   : /var/lib/rabbitmq/mnesia/rabbit at broker1.example.com
erlang version : 5.8.4

- -- rabbit boot start
starting file handle cache server
starting worker pool
starting database
starting codec correctness check
- -- external infrastructure ready
starting plugin registry
starting auth mechanism cr-demo
starting auth mechanism amqplain
starting auth mechanism plain
starting statistics event manager
starting logging server
starting exchange type direct
starting exchange type fanout
starting exchange type headers
starting exchange type topic
- -- kernel ready
starting alarm handler
starting node monitor
starting cluster delegate
starting guid generator
starting memory monitor
- -- core initialized
starting empty DB check
starting federation
starting federation exchange type
starting exchange, queue and binding recovery
starting mirror queue slave sup
starting adding mirrors to queues
- -- message delivery logic ready
starting error log relay
starting networking
starting direct_client
starting notify cluster nodes

broker running

- -- 
James Aimonetti
Distributed Systems Engineer / DJ MC_

2600hz | http://2600hz.com
sip:james at 2600hz.com
tel: 415.886.7905
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/


More information about the rabbitmq-discuss mailing list