Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make RabbitMQ queues failover?

RabbitMQ supports clustering by default, but queues aren't replicated and are bound to the node on which they're created. I'm now looking for ways to make RabbitMQ highly available other than the DRBD solution that they've documented, because it seems like a waste of resources to reserve an entire server that's doing nothing but waiting for the active server to go down.

I'm thinking about a setup in which there are two queues. When a message is published, I want the RabbitMQ cluster to send the message to either of the two queues, whichever one is up. I know that the publisher will get an error if it tries to publish to a queue that's down and that the publisher can try again with the other queue, but I'm wondering whether this can be done automatically at the cluster level so that I don't have to write client code to handle it. Can this be done?

like image 622
Hongli Avatar asked Aug 05 '10 09:08

Hongli


2 Answers

Recently RabbitMQ added active/active native support. http://www.rabbitmq.com/ha.html

like image 192
Vadym Chekan Avatar answered Sep 21 '22 23:09

Vadym Chekan


Have a look at Alternate Exchanges.

It's basically what you asked for, but with exchanges instead of queues. The idea would be to publish to an exchange with an alternate exchange specified (you can do this with any of the RabbitMQ clients). If the message can be delivered to the first, it will. If not (because it can't be reached or because there are no queues bound to it), the alternate is used.

like image 21
scvalex Avatar answered Sep 21 '22 23:09

scvalex