Jason Rowe

Be curious! Choose your own adventure.

RabbitMQ federation examples

In this post I’ll go over a couple simple RabbitMQ federation scenarios and walk through configuration. I’ll give instructions via UI federation management plugin but this can also be done via RabbitMQ management API.

Prerequisites:

In directory C:\Program Files\RabbitMQ Server\rabbitmq_server-[your.version.]\sbin, install federation plugins with the following commands (example in powershell).

& .\rabbitmq-plugins.bat enable rabbitmq_federation
& .\rabbitmq-plugins.bat enable rabbitmq_federation_management

Scenario 1

Your app has a connection to RabbitMQ Server A but would like to consume a message from an exchange on RabbitMQ Server B without managing multiple bus connections. In this situation all the federation configuration will be done on RabbitMQ Server A.

Federation Upstreams Setup.

  • Navigate to Admin > Federation Upstreams
  • Add a new upstream.
  • Enter a name for your upstream (will be used in next steps for policy)
  • amqp://serverbname:port next to URI.(use actual amqp endpoint)
  • Click Add upstream.

Federation Policy Setup.

  • Navigate to Admin > Policies > Add a policy.
  • Enter a descriptive name next to “Name”
  • In “Pattern” you want to use a regex to match the exchange name you want to consume messages from. (Example ^ExchangeNameYouWantToFederate$)
  • choose “Exchanges” from the “Apply to” drop down list
  • For “Policy” enter federation-upstream: [upstream name from setup above] “Policy”.
  • Click Add policy.

Scenario 2

Your app has a connection to RabbitMQ Server A and uses virtual host named “Foo” but would like to consume a message from an exchange on RabbitMQ Server B which is using the default virtual host. In this situation all the federation configuration will be done on RabbitMQ Server A again. The only big different from scenario 1 is the virtual host needs to be specified in the ampq endpoint and upstream.

Federation Upstreams Setup.

  • Navigate to Admin > Federation Upstreams
  • Add a new upstream.
  • Select Foo virtual host
  • Enter a name for your upstream (will be used in next steps for policy)
  • amqp://serverbname:port/%2F (the %2F is a ‘/’ which connects to the default virtual host)
  • Click Add upstream.

The federation policy setup is exactly the same as scenario 1.


Posted

in

by

Tags:

Comments

2 responses to “RabbitMQ federation examples”

  1. Jai Singh Avatar
    Jai Singh

    In this situation all the federation configuration will be done on RabbitMQ Server A. – Is it typo? fed conf is done on downstream . right ? so in this it should be Server B ?

  2. Jason Avatar
    Jason

    That is why I wrote this down because it was so confusing. I stopped thinking of it as upstream and downstream and just think in terms of where the consumer and publisher are. If the consumer is on a different host it needs to have a policy setup to federate the exchanges.

Leave a Reply

Your email address will not be published. Required fields are marked *