<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Dec 14, 2010, at 5:04 AM, Mark Hudson wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; color: rgb(68, 68, 68); "><div>Two questions on resolving RabbitMQ broker hostnames</div><div><br></div><div>
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 ?</div>
<div><br></div></span></blockquote><br></div><div>You could use HAProxy:</div><div><br></div><div><a href="http://haproxy.1wt.eu/">http://haproxy.1wt.eu/</a></div><div><br></div><div>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.</div><div><br></div><blockquote type="cite"><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; color: rgb(68, 68, 68); "><div>2. When a broker is taken down, any&nbsp;connected&nbsp;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 ?</div></span></blockquote><div><br></div>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.<div><br></div><div>I know there's been some work recently in Spring AMQP to make this reconnection stuff less painful...<br><div>
<div style="font-family: Helvetica; font-size: 12px; "><font class="Apple-style-span" face="Courier"><br class="Apple-interchange-newline">Thanks!</font></div><div style="font-family: Helvetica; font-size: 12px; "><font class="Apple-style-span" face="Courier"><br class="webkit-block-placeholder"></font></div><div style="font-family: Helvetica; font-size: 12px; "><font class="Apple-style-span" face="Courier">Jon Brisbin</font></div><div style="font-family: Helvetica; font-size: 12px; "><font class="Apple-style-span" face="Courier"><br></font></div><div style="font-family: Helvetica; font-size: 12px; "><font class="Apple-style-span" face="Courier">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;Web: <a href="http://jbrisbin.com/">http://jbrisbin.com/</a></font></div><div style="font-family: Helvetica; font-size: 12px; "><font class="Apple-style-span" face="Courier">&nbsp;&nbsp; &nbsp;Twitter: @j_brisbin</font></div><div style="font-family: Helvetica; font-size: 12px; "><font class="Apple-style-span" face="Courier">&nbsp;&nbsp; &nbsp; &nbsp;Skype: jon.brisbin</font></div>
</div>
<br></div></body></html>