Installation of Federation Exchange Plugin in RabbitMQ
Introduction –
RabbitMQ is a lightweight, open-source message broker that supports a variety of messaging protocols such as AMQP, MQTT, and STOMP. To provide high availability, it can be installed as a cluster. When your application is deployed in numerous geographic regions, maintaining a single cluster for all of them becomes extremely difficult, as latency enters the picture and complexity rises. You can maintain numerous, independent RabbitMQ Clusters and federate messages between them using the RabbitMQ Federation Plugin.
Types of Federation –
- Exchange Federation:
With the exchange Federation, it is possible to distribute messages to another cluster. It means, messages published on federated exchanges, will be published to local exchange plus downstream servers as well. It can be used when the same message you want to consume at multiple places. - Queue Federation:
Queue federation does intelligent load balancing of messages, it will only send messages to downstream servers when there will consumers available to consume. It means messages are not duplicated. It is useful to distribute load or migration of clusters.
Prerequisites –
- Two Rabbitmq Servers/Cluster
- Management plugin enabled for dashboard
- Connectivity between both servers/Cluster over amqp protocol on port 5672.
Install Federation Plugin –
sudo rabbitmq-plugins enable rabbitmq_federation rabbitmq_federation_management
Restart Rabbitmq Server, for configurations to take effect
Setup Exchange Federation –
We have executed On both Upstream and Downstream Server:
1. First Create a user for federation.
2. Create a Vhost in which exchange will be created to federate.
3. Give user access to the above-created vhost.
4. Create an exchange that is to be federated in the above-created vhost.
5. Create a Queue in test_vhost
6. Bind Queue with Exchange
On Downstream Server –
1. Create Federation Upstreams.
The URI will be in the format:
amqp://<federation_username>:<federation_password>@<IP/DNS_of_upstream_server>:5672/<vhost_name>
In this example: amqp://federation_user:federation_user@X.X.X.X:5672/test_vhost
2. Create a Policy for federation.
3. Check Federation Status, it should be running.
Here Exchange federation setup is completed.
#Test Federation
1. Publish message on the exchange on Upstream server.
Now, the message should be present on the upstream and downstream queues.