[rabbitmq-discuss] Resolving hostnamesfor high availability
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...
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the rabbitmq-discuss