[rabbitmq-discuss] How can I connect in a cluster using Java library

Matthew Sackman matthew at rabbitmq.com
Thu Mar 17 16:10:16 GMT 2011


Greetings!

On Thu, Mar 17, 2011 at 08:52:40AM -0700, Lucas Souza wrote:
> Do you recommend that I use a HAProxy in front my Rabbits? Or Can I do
> this:
> 
> ConnectionFactory factory = new ConnectionFactory();
> Address[] addresses = {new Address("localhost", 12345), new
> Address("localhost", 12346)};
> factory.newConnection(addresses);

You can certainly do that. However, that's baking into your code both
ports and addresses, which means that should you need to migrate your
cluster/ha-setup elsewhere, you'll have to recompile your clients. Thus
it might be better to us something like ha-proxy, or maybe just
DNS (round-robin or not) with a very short TTL will suffice. There are
many ways to skin this particular Rabbit...

Matthew


More information about the rabbitmq-discuss mailing list