[rabbitmq-discuss] Resolving hostnamesfor high availability

Jon Brisbin jon at jbrisbin.com
Tue Dec 14 12:24:57 GMT 2010

On Dec 14, 2010, at 5:04 AM, Mark Hudson wrote:

> Two questions on resolving RabbitMQ broker hostnames
> 1.I'm able to cluster 2 or more rabbitmq brokers on different machines, but to send a message I need to specify a hotsname/ipaddress. For redundancy, is there some way to look up all the hosts within a cluster so I can pick a running broker ?

You could use HAProxy:


You get round-robin load balancing and failover, though you could skip the load balancing and just use it for failover. Then your clients always point to the proxy and you never have to change them, even if you add 20 brokers on the backend.

> 2. When a broker is taken down, any connected consumers/producers get an exception. Do I catch the exception and try to recconect to a live broker - this relates to question 1 - or is there some other mechanism to handle this ?

Reconnection is not easy. I've found it's best to keep your app aware enough of what consumers it has open at any time such that it can re-establish those consumers when the connection/channel gets re-created.

I know there's been some work recently in Spring AMQP to make this reconnection stuff less painful...


Jon Brisbin

        Web: http://jbrisbin.com/
    Twitter: @j_brisbin
      Skype: jon.brisbin

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20101214/438addd2/attachment.htm>

More information about the rabbitmq-discuss mailing list