How do I set up the RabbitMQ Federation plugin on my Amazon MQ broker?

Last updated: 2022-04-19

I want to distribute messages from an on-premises broker to an Amazon MQ for RabbitMQ broker using the RabbitMQ Federation plugin. How do I set up my Amazon MQ for RabbitMQ broker to work with the RabbitMQ Federation plugin?

Short description

To set up the RabbitMQ Federation plugin on an Amazon MQ for RabbitMQ broker, you must configure the following on the downstream broker:

  • One or more federation-upstream parameters that define the federation connections to remote queues or exchanges.
  • A RabbitMQ policy that allows specific remote queues or exchanges to become federated.
  • An exchange with a new queue bound to it to receive messages.

Resolution

Note: The following procedure requires two brokers: An upstream broker (on premises or cloud based) and a downstream broker (the Amazon MQ for RabbitMQ broker).

Create one or more federation-upstream parameters that define the federation connections to remote queues or exchanges

1.    Open the Amazon MQ console.

2.    In the left navigation pane, choose Brokers.

3.    In the Name column, choose the name of your downstream broker.

4.    In the Connections pane, select the URL that's listed below RabbitMQ web console. The RabbitMQ web console login page for your downstream broker opens.

5.    Enter your Username and Password for your broker. Then, choose Login to log in to the RabbitMQ web console.

6.    In the RabbitMQ web console, choose the Admin tab. Then, in the right navigation pane, choose Federation Upstreams.

7.    Choose Add a new upstream.

8.    For Name, enter a name for your upstream parameter.

9.    For URI, delete the default amqp:// text and enter the upstream broker's URI in the following format:

amqps://$UPSTREAM_BROKER_USER:$UPSTREAM_BROKER_PASSWORD@$UPSTREAM_BROKER_ENDPOINT:5671

10.    Choose Add upstream.

Create a RabbitMQ policy that allows specific remote queues or exchanges to become federated

1.    Open the RabbitMQ web console of the downstream broker. For instructions, see steps 1-5 of the To create a federation-upstream parameter using the RabbitMQ web console section of this article.

2.    Choose the Admin tab. Then, in the right navigation pane, choose Policies.

3.    Choose Add / update a policy.

4.    For Name, enter a name for your policy.

5.    For Pattern, enter a regular expression that matches the queues or exchange names that you want to allow to become federated.

6.    For Apply to, select Exchanges from the dropdown list.

Note: Applying the policy to Exchanges allows the policy to be applied to exchanges in the downstream broker only.

7.    For Priority, enter the numeral 1.

Note: The Priority setting is used to determine which policy should be applied to an exchange or queue if multiple policies have the same name. Specifying the Priority setting as 1 prevents any default Amazon MQ policies that have the same name from overriding the policy.

8.    For Definition, enter federation-upstream-set as the key in the first text box, before the = sign. Then, enter all as the value in the second text box, to the right of the = sign.

9.    Choose Add / update policy.

Create an exchange with a new queue bound to it to receive messages

1.    Open the RabbitMQ web console of the downstream broker. For instructions, see steps 1-5 of the To create a federation-upstream parameter using the RabbitMQ web console section of this article.

2.    Choose the Queues tab.

3.    Under Add a new queue, for Name, enter a name for the new queue that is receiving messages.

4.    Choose Add queue.

5.    Choose the Exchanges tab.

6.    Under Add a new exchange, for Name, enter the regular expression that matches exchange name that you used when creating the RabbitMQ policy.

7.    Choose Add exchange.

Note: RabbitMQ also creates an exchange on the upstream broker that has the same name automatically.

8.    Choose the Exchanges tab.

9.    Under All exchanges, choose the name of the new exchange that you created.

10.    Under Bindings, for Add binding from this exchange, select To queue from the dropdown list. Then, enter the name of the queue that you created.

11.    For Routing key, enter a value of your choice. The messages sent to the exchange on the upstream broker using this value are also sent to the queue bound to this exchange.

12.    Choose Bind.

To test the setup

Send a test message to the upstream broker's source exchange

1.    Open the RabbitMQ web console of the upstream broker.

Note: For more information about how to access the RabbitMQ web console, see Management plugin in the RabbitMQ documentation.

2.    Choose the Exchanges tab. Then, select the source exchange's name.

3.    In the left navigation pane, choose Publish message. The Publish message section opens.

4.    In the Routing key text box, enter the routing key value that you created.

5.    In the Payload text box, enter a test message.

Note: You can leave the Headers and Properties text boxes blank.

6.    Choose the Publish message button. The test message is sent to the source exchange. If your federation parameter is configured correctly, then the message is also sent to the downstream broker's destination queue.

Verify that the test message is received by the downstream broker's destination queue

1.    Open the RabbitMQ web console of the downstream broker.

2.    Choose the Queues tab. Then, choose the destination queue's name.

3.    In the left navigation pane, choose Get messages. The Get messages section opens.

4.    Choose the Get messages button. If the federation parameter is configured correctly, the test message that you sent to the source exchange appears as the Payload value.


Did this article help?


Do you need billing or technical support?