ARTEMIS-2074 URI not transposing ServerLocator on ConnectionFactory

This closes #2286
As it superceedes it
This commit is contained in:
Clebert Suconic 2018-09-04 15:15:06 -04:00
parent 5b52780c6a
commit d2d9a0e634
7 changed files with 34 additions and 4 deletions

View File

@ -67,6 +67,14 @@ public class ActiveMQConnectionFactory extends JNDIStorable implements Connectio
private static final long serialVersionUID = 6730844785641767519L;
public ServerLocator setUseTopologyForLoadBalancing(boolean useTopologyForLoadBalancing) {
return serverLocator.setUseTopologyForLoadBalancing(useTopologyForLoadBalancing);
}
public boolean getUseTopologyForLoadBalancing() {
return serverLocator.getUseTopologyForLoadBalancing();
}
private ServerLocator serverLocator;
private String clientID;

View File

@ -36,4 +36,13 @@ public abstract class AbstractCFSchema extends URISchema<ActiveMQConnectionFacto
return BeanSupport.setData(uri, new JMSConnectionOptions(), query);
}
protected ActiveMQConnectionFactory setData(URI uri,
Map<String, String> query,
ActiveMQConnectionFactory factory) throws Exception {
BeanSupport.setData(uri, factory.getServerLocator(), query);
return BeanSupport.setData(uri, factory, query);
}
}

View File

@ -39,7 +39,9 @@ public class InVMSchema extends AbstractCFSchema {
String name) throws Exception {
JMSConnectionOptions options = newConectionOptions(uri, query);
ActiveMQConnectionFactory factory = ActiveMQJMSClient.createConnectionFactoryWithoutHA(options.getFactoryTypeEnum(), InVMTransportConfigurationSchema.createTransportConfiguration(uri, query, name, "org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory"));
return BeanSupport.setData(uri, factory, query);
BeanSupport.setData(uri, factory, query);
BeanSupport.setData(uri, factory.getServerLocator(), query);
return factory;
}
@Override

View File

@ -52,7 +52,7 @@ public class JGroupsSchema extends AbstractCFSchema {
} else {
factory = ActiveMQJMSClient.createConnectionFactoryWithoutHA(dcConfig, options.getFactoryTypeEnum());
}
return BeanSupport.setData(uri, factory, query);
return setData(uri, query, factory);
}
@Override

View File

@ -57,7 +57,7 @@ public class TCPSchema extends AbstractCFSchema {
factory = ActiveMQJMSClient.createConnectionFactoryWithoutHA(options.getFactoryTypeEnum(), tcs);
}
return BeanSupport.setData(uri, factory, query);
return setData(uri, query, factory);
}
@Override

View File

@ -49,7 +49,7 @@ public class UDPSchema extends AbstractCFSchema {
} else {
factory = ActiveMQJMSClient.createConnectionFactoryWithoutHA(dgc, options.getFactoryTypeEnum());
}
return BeanSupport.setData(uri, factory, query);
return setData(uri, query, factory);
}
@Override

View File

@ -719,4 +719,15 @@ public class SimpleJNDIClientTest extends ActiveMQTestBase {
connection.close();
}
@Test
public void testUseTopologyForLoadBalancing() throws Exception {
Hashtable<String, String> props = new Hashtable<>();
props.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory");
props.put("connectionFactory.ConnectionFactory", "vm://0?useTopologyForLoadBalancing=false");
Context ctx = new InitialContext(props);
ConnectionFactory connectionFactory = (ConnectionFactory) ctx.lookup("ConnectionFactory");
assertFalse(((ActiveMQConnectionFactory)connectionFactory).getServerLocator().getUseTopologyForLoadBalancing());
}
}