Justin Bertram commented on ARTEMIS-1733:

For the initial connection the RoundRobinConnectionLoadBalancingPolicy can only 
work with what you give it so if you only provide a single server in your URL 
then there is only one to choose from when the initial connection is made.  
Once the initial connection is made then the client will receive the topology 
from the cluster so the next connection which is made will be to a different 
broker assuming you using the same ConnectionFactory or ServerLocator instance.

Here is an example of specifying multiple hosts in a single URL:


> RoundRobinConnectionLoadBalancingPolicy always connect to the 1st broker at 
> startup
> -----------------------------------------------------------------------------------
>                 Key: ARTEMIS-1733
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-1733
>             Project: ActiveMQ Artemis
>          Issue Type: Bug
>            Reporter: Laurent Bigonville
>            Priority: Major
> Hi,
> When using the client-side-load-balancing from apache activemq artemis 
> examples on my own setup (2 RH amq) I see that the first connection is always 
> going to the same broker. The documentation says that 
> RoundRobinConnectionLoadBalancingPolicy should 1st pick up a random broker 
> and then do round-robin, but that 1st step doesn't seems to work.
> I've the the following string in the jndi.properties and starting the example 
> with mvn -PnoServer verify:
> java.naming.factory.initial=org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory
> connectionFactory.ConnectionFactory=tcp://foo.example.com?user=user;password=password
> queue.queue/exampleQueue=exampleQueue
> Adding some printnl() in the select() function of 
> RoundRobinConnectionLoadBalancingPolicy, I see that pos = 
> RandomUtil.randomInterval(0, max); is being called with max value of 1 the 
> 1st time(should be 2 as there are two servers). The subsequent calls to that 
> functions show that max value is then set to 2 as expected.
> This explains why I always get my applications to connect to the same broker.

This message was sent by Atlassian JIRA

Reply via email to