[rabbitmq-discuss] Federation help

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


-----BEGIN PGP SIGNED MESSAGE-----
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:

[{rabbitmq_federation
  ,[{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,
"broker2"}]]}
                          ,{"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
broker2.example.com:/:control

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:

...snip...
{server_initiated_close,406,
                      <<"PRECONDITION_FAILED - cannot redeclare exchange
'control' in vhost '/' with different type, durable, internal or
autodelete value">>}},
              {gen_server,call,
                  [<0.78.0>,
                   {call,
                       {'exchange.declare',1,<<"control">>,<<"direct">>,
                           false,false,false,false,false,[]},
...snip...

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:
{amqp_error,not_found,
            "no exchange 'federation: control -> broker2.example.com B'
in vhost '/'",
            'exchange.delete'}

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.

James

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 :
/var/lib/rabbitmq/rabbitmq_server-2.7.0/sbin/../ebin/rabbit.app
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
...done
starting worker pool
...done
starting database
...done
starting codec correctness check
...done
- -- external infrastructure ready
starting plugin registry
...done
starting auth mechanism cr-demo
...done
starting auth mechanism amqplain
...done
starting auth mechanism plain
...done
starting statistics event manager
...done
starting logging server
...done
starting exchange type direct
...done
starting exchange type fanout
...done
starting exchange type headers
...done
starting exchange type topic
...done
- -- kernel ready
starting alarm handler
...done
starting node monitor
...done
starting cluster delegate
...done
starting guid generator
...done
starting memory monitor
...done
- -- core initialized
starting empty DB check
...done
starting federation
...done
starting federation exchange type
...done
starting exchange, queue and binding recovery
...done
starting mirror queue slave sup
...done
starting adding mirrors to queues
...done
- -- message delivery logic ready
starting error log relay
...done
starting networking
...done
starting direct_client
...done
starting notify cluster nodes
...done

broker running


- -- 
James Aimonetti
Distributed Systems Engineer / DJ MC_

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

iQEcBAEBAgAGBQJO0S94AAoJENc77s1OYoGg79gIAJwI7bN1cgq2vgz+Wk/rtqUm
KWxKdMvn6tH4kfPK6LPEw2lviXBesE9KJ7oSv/4GCWKlRRxoQ5DqKyIWyfuJDZ15
HYpbq8Ne1hdDzmtFCtUR6FhTBg5Oor9atO9EMdCZCQ3IKWLE3rsE71Mek4lvFtYu
8QMxHHTZ1lDWUJtHpzrpUNG0KLKkpz67gACP4cXsjLDggFZHwc1wZpcFko7odgld
0LSoPA7qZzqPfwnZ8LabPmD3tCKGelTQolkl8P6YGtMGrbwzFDhav/KFVUYTEGuP
JOqOmyPi6d4X+/gCtxiRwtde1X4EPaEVQpB4BC7ttmny7rbimLLz6Vjwc4biFGE=
=OppA
-----END PGP SIGNATURE-----


More information about the rabbitmq-discuss mailing list