Skip to content

Instantly share code, notes, and snippets.

@achmadns
Last active September 19, 2016 18:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save achmadns/4a05b4167080c106e417 to your computer and use it in GitHub Desktop.
Save achmadns/4a05b4167080c106e417 to your computer and use it in GitHub Desktop.
# assuming we want forward message published to exchange ams.* from broker A to broker B
# there is no any configuration update on broker A except credential needed by B to connect the upstream
# see https://www.rabbitmq.com/federation.html for details
# do these on broker B
# enable rabbitmq federation plugin
rabbitmq-plugins enable rabbitmq_federation
# enable rabbitmq federation web management plugin
rabbitmq-plugins enable rabbitmq_federation_management
# restart the broker
service rabbitmq-server restart
# create a queue for testing purpose
rabbitmqadmin declare queue name=event durable=true auto_delete=false
# create binding for it
rabbitmqadmin declare binding source=amq.topic destination_type=queue destination=event routing_key=amq.event
# define the upstream, this will create a binding on upstream broker
rabbitmqctl set_parameter federation-upstream my-upstream '{"uri":"amqp://guest:guest@10.10.10.10:5672","expires":3600000}'
# define the exchanges that will be federated, upstream broker must have the defined exchange
rabbitmqctl set_policy --apply-to exchanges federate-me "^amq\." '{"federation-upstream-set":"all"}'
# try to publish a message on broker A and see
rabbitmqadmin publish exchange=amq.topic routing_key=amq.event payload="Hello Rabbit!"
# check whether the message is forwarded to broker B, you should get a message contains 'Hello Rabbit!'
rabbitmqadmin get queue=event requeue=false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment