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

Emile Joubert emile at rabbitmq.com
Wed Mar 16 15:12:44 GMT 2011


Hi Lucas,

On 16/03/11 14:46, Lucas Souza wrote:
> But, I'm exploring the source code of rabbitmq java client library and
> saw the class https://github.com/rabbitmq/rabbitmq-java-client/blob/master/src/com/rabbitmq/client/ConnectionFactory.java
>
> In this class when I send multiples addresses, it connect in only one.
> What node adress should I send to newConnection method?

If you are connecting to single broker then use setHost() and 
newConnection(). If you are connecting to a cluster then can do the 
same, using the address of any of the cluster nodes, or you can use 
newConnection(Address[]), where the parameter is an array of cluster 
node addresses.

> Sorry if I'm wrong, but I understand that if I send a address of a
> node valid, the connection returned is always references this node.

Yes.



Regards

Emile


More information about the rabbitmq-discuss mailing list