How to configure RabbitMQ shovel?

7.4k views Asked by At

I have 2 RabbitMQ clusters in separate datacenters. At this moment i need to shovel one of the exchanges from an one rabbit to the other. How can i achieve it?

2

There are 2 answers

3
Sergii Zhevzhyk On

The shovel plugin is the best fit for this task helping to reliably and continually move messages between clusters (or within the same cluster). This plugin is included in the RabbitMQ distribution and is easy to enable (it can be configured on one of the clusters):

rabbitmq-plugins enable rabbitmq_shovel

If you prefer UI enable the management plugin for the Management UI:

rabbitmq-plugins enable rabbitmq_shovel_management 

The next step is to define the dynamic shovel itself (if you are planning to move messages between the clusters on a permanent basis then use the static shovel). Declaration of a shovel is defined pretty well in the documentation. Please take into account that you need to configure src-exchange and dest-exchange instead of src-queue and dest-queue.

0
Paw Baltzersen On

To supplement on Sergii's answer, here is how I create a shovel from my production cluster to the test cluster.

call rabbitmqctl.bat set_parameter shovel [shovel_name] "{""src-protocol"": ""amqp091"", ""src-uri"":""amqp://[username]:[password]@localhost"", ""src-exchange"": ""[source_exchange]"", ""src-exchange-key"": ""#"", ""dest-protocol"": ""amqp091"", ""dest-uri"": ""amqp://[username]:[password]@[target_cluster_server]"", ""dest-exchange"": ""[target_exchange]""}"

It creates a dynamic shovel, which I prefer because it will automatically copy itself to other nodes in the source cluster.

You can provide multiple destinations in dest-uri, so if a target node is down the shovel will try another.

src-exchange-key is because the source is a topic exchange.

I don't think there is any way to check the behaviour other than see if the target exchange receives what you'd expect.

https://www.rabbitmq.com/shovel.html#clustering