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

Lucas Souza lucasas at gmail.com
Wed Mar 16 14:46:44 GMT 2011


Thanks Emile, I understand that does not matter to the client which
node his are connected.

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?

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.

Thank you again.

Regards

On 16 mar, 11:23, Emile Joubert <em... at rabbitmq.com> wrote:
> Hi Lucas,
>
> On 16/03/11 13:48, Lucas Souza wrote:
>
> > ConnectionFactory factory = new ConnectionFactory();
> > Address[] addresses = {new Address("localhost", 12345), new
> > Address("localhost", 12346)};
> > factory.newConnection(addresses);
>
> > If I'll do this, how can I know what node of cluster I'm connected?
>
> It shouldn't matter which node you are connected to (unless you care
> about the locations of queues). Clients see an identical view of the
> world regardless of which broker in the same cluster they connect to.
>
> A channel can query the underlying connection. You can find the address
> of the clustered node that way if necessary.
>
> > If node 1 down, but node 2 still up, how can I reconnect in node 1?
>
> The factory connection does not offer robust reconnection logic. If you
> want clients to reconnect then take a look at the message patterns library:
>
> http://hg.rabbitmq.com/rabbitmq-java-messagepatterns
>
> This is a higher-level library that offers reconnection logic, which is
> sufficiently flexible for use with clusters.
>
> Regards
>
> Emile
>
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-disc... at lists.rabbitmq.comhttps://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss


More information about the rabbitmq-discuss mailing list