Source:
public void testConnectionLoadBalancingUsingInitialConnectors() throws Exception { final String ADDRESS = "queues.testaddress"; final String QUEUE = "queue0"; final String URL = "(tcp://localhost:61616,tcp://localhost:61617)"; final int CONNECTION_COUNT = 50; setupCluster(); startServers(); for (int i = 0; i < 5; i++) { setupSessionFactory(i, isNetty()); } for (int i = 0; i < 5; i++) { createQueue(i, ADDRESS, QUEUE, null, false); } for (int i = 0; i < 5; i++) { addConsumer(i, i, QUEUE, null); } for (int i = 0; i < 5; i++) { waitForBindings(i, ADDRESS, 1, 1, true); } for (int i = 0; i < 5; i++) { waitForBindings(i, ADDRESS, 4, 4, false); } int[] baseline = new int[5]; for (int i = 0; i < 5; i++) { baseline[i] = servers[i].getActiveMQServerControl().getConnectionCount(); } ClientSessionFactory[] clientSessionFactories = new ClientSessionFactory[CONNECTION_COUNT]; ServerLocator locator = ActiveMQClient.createServerLocator(URL).setUseTopologyForLoadBalancing(false); for (int i = 0; i < CONNECTION_COUNT; i++) { clientSessionFactories[i] = addSessionFactory(locator.createSessionFactory()); } assertEquals(CONNECTION_COUNT / 2, (servers[0].getActiveMQServerControl().getConnectionCount() - baseline[0])); assertEquals(CONNECTION_COUNT / 2, (servers[1].getActiveMQServerControl().getConnectionCount() - baseline[1])); for (int i = 0; i < CONNECTION_COUNT; i++) { clientSessionFactories[i].close(); } locator.setUseTopologyForLoadBalancing(true); for (int i = 0; i < CONNECTION_COUNT; i++) { clientSessionFactories[i] = addSessionFactory(locator.createSessionFactory()); } for (int i = 0; i < 5; i++) { assertTrue((servers[i].getActiveMQServerControl().getConnectionCount() - baseline[i]) < (CONNECTION_COUNT / 2)); } }

Target:
public void testConnectionLoadBalancingUsingInitialConnectors() throws Exception { final String ADDRESS = "queues.testaddress"; final String QUEUE = "queue0"; final String URL = "(tcp://localhost:61616,tcp://localhost:61617)?useTopologyForLoadBalancing=false"; final int CONNECTION_COUNT = 50; setupCluster(); startServers(); for (int i = 0; i < 5; i++) { setupSessionFactory(i, isNetty()); } for (int i = 0; i < 5; i++) { createQueue(i, ADDRESS, QUEUE, null, false); } for (int i = 0; i < 5; i++) { addConsumer(i, i, QUEUE, null); } for (int i = 0; i < 5; i++) { waitForBindings(i, ADDRESS, 1, 1, true); } for (int i = 0; i < 5; i++) { waitForBindings(i, ADDRESS, 4, 4, false); } int[] baseline = new int[5]; for (int i = 0; i < 5; i++) { baseline[i] = servers[i].getActiveMQServerControl().getConnectionCount(); } ClientSessionFactory[] clientSessionFactories = new ClientSessionFactory[CONNECTION_COUNT]; ServerLocator locator = ActiveMQClient.createServerLocator(URL); for (int i = 0; i < CONNECTION_COUNT; i++) { clientSessionFactories[i] = addSessionFactory(locator.createSessionFactory()); } assertEquals(CONNECTION_COUNT / 2, (servers[0].getActiveMQServerControl().getConnectionCount() - baseline[0])); assertEquals(CONNECTION_COUNT / 2, (servers[1].getActiveMQServerControl().getConnectionCount() - baseline[1])); for (int i = 0; i < CONNECTION_COUNT; i++) { clientSessionFactories[i].close(); } locator.setUseTopologyForLoadBalancing(true); for (int i = 0; i < CONNECTION_COUNT; i++) { clientSessionFactories[i] = addSessionFactory(locator.createSessionFactory()); } for (int i = 0; i < 5; i++) { assertTrue((servers[i].getActiveMQServerControl().getConnectionCount() - baseline[i]) < (CONNECTION_COUNT / 2)); } }