[rabbitmq-discuss] Ordering of messages from a fanout exchange

Matthew Sackman matthew at lshift.net
Tue Mar 16 17:08:31 GMT 2010

Hi James,

On Tue, Mar 16, 2010 at 09:46:22AM -0700, James Pettit wrote:
> I'm trying to get high availability with live failover. Both nodes would be
> bound to the same fanout exchange, and keep synchronized by the fact that
> message come to each in the same order. I do realize now why this is
> impossible - the same virtual exchange might be multiple physical machines,
> and if order were required, these would have to communicate to each other
> before sending any message, a terrible toll for performance. I believe the
> correct way to do this is to have one of my live nodes be the designated
> master, and the master can send the ordering of events to all secondary
> nodes (to maintain state in sync). The secondary nodes could then determine
> when the master is down and one of them can take up the baton, as it were.
> In this case, all that's required is the ordering on messages from the same
> channel (the master). Anything wrong with this scenario?

Err, this suggests there is only one producer. The channel here is a
single channel within a connection. One way to get what you want is to
use the shovel. Apologies for the ASCII art:

                            Node A
Producers >--\ 
              >-> exchangeA ---> queueA ---> shovelA -\
(various) >--/                                        |
             |                /--> queueB --> shovelB ---> [to node B]
             \--> exchangeB -<
                              \--> queueC --> shovelC ---> [to node C]

The reason why this works is because there is only one thing (shovelA)
that publishes to exchangeB. As such, you can guarantee that the
messages will be in queues B and C in the same order, and then picked up
by shovels B and C and routed onto nodes B and C. However, many
different producers can send messages into exchange A, and they can (and
will be) processed in an ordering that only preserves ordering within a

I hope that helps.


More information about the rabbitmq-discuss mailing list