8

Is it possible to use federations or shovels to mirror the creation of exchanges and queues on one server to another ?

All the examples I've seen of using shovels and federations use exchanges and queues that already exist on the servers. What I want to do is create an exchange on server A and have a federation or shovel re-create it on Server B then start to send messages to it.

If this cannot be done with a federation or shovel is there anyway of achieving this without using clustering, the connection between the two servers is not consistent so clustering isn't possible.

I'm running RabbitMQ on windows.

Matteo
  • 37,680
  • 11
  • 100
  • 115
user1450877
  • 421
  • 5
  • 16

2 Answers2

11

You can use the federation plug-in.

It supports the exchange exchange and the queue federation, in order to mirror the queues and exchanges you can configure a policies ( using the management console or command line),for example with this parameters:

Name: my_policy 
Pattern: ^mirr\.  <---- mirror exchanges and queues with prefix “mirr.” 
Definition: federation-upstream-set:all 

you can apply the configuration for exchanges and queues, as:

enter image description here

The pattern policy supports regular expression

In this way each new or old exchange or queue that starts with the prefix “mirr.” will be mirrored to the other broker.

I think this could solve your problem.

Gabriele Santomaggio
  • 21,656
  • 4
  • 52
  • 52
  • 1
    BTW, while this is nifty solution I would add following from the documentation `The bindings are sent upstream asynchronously - so the effect of adding or removing a binding is only guaranteed to be seen eventually` – pinepain Apr 17 '14 at 06:31
  • 1
    Yes, thank you @zaq178miami ! It's a big difference from the mirror with the cluster! – Gabriele Santomaggio Apr 17 '14 at 06:49
  • federated queues are actually quite a new option. @OP: what RabbitMQ version are you using? – Sigi Apr 17 '14 at 15:31
  • 1
    Thanks Gas, looks like I bought the wrong RabbingMQ book :) – user1450877 Apr 19 '14 at 12:06
  • 1
    You are welcome :)! Maybe the book are you reading is a bit old. – Gabriele Santomaggio Apr 19 '14 at 17:27
  • The exchanges/queues are created, but a queue normally has a binding to an exchange and this is not recreated. So e.g.: rabbit1: Ex1 <- Q1, rabbit2: Ex1 (without binding to) Q1, Q1 on rabbit2 is federated from rabbit1 and auto created, but the binding to Ex1 is missing, how you solve this? – Oleg Majewski Jun 10 '15 at 18:46
2

Unfortunately in this way it is not possible to do this, because the connection is a point-to-point connection. You have to link a exchange with a remote exchange and in your topology this cant be created automatically.

I had also this problem in the past. And how i resolved the problem was over a business logic side. If there was a need for a new Exchange/Queue "on the fly", my data input gateway recognized this and created on the local and on the remote exchange the new exchange and queues with the connection, before the message was sent to RabbitMQ.

Rene Herget
  • 1,506
  • 13
  • 28