diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQConnectionFactory.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQConnectionFactory.java index df4611e442..77091927ab 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQConnectionFactory.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQConnectionFactory.java @@ -67,11 +67,11 @@ public class ActiveMQConnectionFactory extends JNDIStorable implements Connectio private static final long serialVersionUID = 6730844785641767519L; - public ServerLocator setUseTopologyForLoadBalancing(boolean useTopologyForLoadBalancing) { - return serverLocator.setUseTopologyForLoadBalancing(useTopologyForLoadBalancing); + public void setUseTopologyForLoadBalancing(boolean useTopologyForLoadBalancing) { + serverLocator.setUseTopologyForLoadBalancing(useTopologyForLoadBalancing); } - public boolean getUseTopologyForLoadBalancing() { + public boolean isUseTopologyForLoadBalancing() { return serverLocator.getUseTopologyForLoadBalancing(); } diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAProperties.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAProperties.java index e56e80d991..10b281d922 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAProperties.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAProperties.java @@ -20,6 +20,7 @@ import java.io.Serializable; import java.util.Hashtable; import org.apache.activemq.artemis.api.core.ActiveMQException; +import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.utils.PasswordMaskingUtil; /** @@ -37,6 +38,8 @@ public class ActiveMQRAProperties extends ConnectionFactoryProperties implements private static boolean trace = ActiveMQRALogger.LOGGER.isTraceEnabled(); protected boolean allowLocalTransactions; + protected boolean useTopologyForLoadBalancing = ActiveMQClient.DEFAULT_USE_TOPOLOGY_FOR_LOADBALANCING; + /** * The user name */ @@ -250,6 +253,14 @@ public class ActiveMQRAProperties extends ConnectionFactoryProperties implements initialized = true; } + public void setUseTopologyForLoadBalancing(boolean useTopologyForLoadBalancing) { + this.useTopologyForLoadBalancing = useTopologyForLoadBalancing; + } + + public boolean isUseTopologyForLoadBalancing() { + return useTopologyForLoadBalancing; + } + public String getCodec() { return passwordCodec; } diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQResourceAdapter.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQResourceAdapter.java index 0b4cbb4a9a..7a21184a66 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQResourceAdapter.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQResourceAdapter.java @@ -908,6 +908,14 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { raProperties.setProducerMaxRate(producerMaxRate); } + public void setUseTopologyForLoadBalancing(boolean useTopologyForLoadBalancing) { + raProperties.setUseTopologyForLoadBalancing(useTopologyForLoadBalancing); + } + + public boolean isUseTopologyForLoadBalancing() { + return raProperties.isUseTopologyForLoadBalancing(); + } + /** * Get producer window size * @@ -1792,6 +1800,8 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { throw new IllegalArgumentException("must provide either TransportType or DiscoveryGroupAddress and DiscoveryGroupPort for ResourceAdapter Connection Factory"); } + cf.setUseTopologyForLoadBalancing(raProperties.isUseTopologyForLoadBalancing()); + cf.setEnableSharedClientID(true); cf.setEnable1xPrefixes(raProperties.isEnable1xPrefixes() == null ? false : raProperties.isEnable1xPrefixes()); setParams(cf, overrideProperties); diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/ra/ActiveMQResourceAdapterConfigTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/ra/ActiveMQResourceAdapterConfigTest.java index 0473db406f..8d923b7ecd 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/ra/ActiveMQResourceAdapterConfigTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/ra/ActiveMQResourceAdapterConfigTest.java @@ -420,6 +420,12 @@ public class ActiveMQResourceAdapterConfigTest extends ActiveMQTestBase { " Enable1xPrefixes" + " boolean" + " " + + " " + + " " + + " ***add***" + + " UseTopologyForLoadBalancing" + + " boolean" + + " " + " "; private static String rootConfig = "" + config + commentedOutConfigs + ""; diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/ra/ConnectionFactoryPropertiesTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/ra/ConnectionFactoryPropertiesTest.java index b463e30383..4f0885f5ba 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/ra/ConnectionFactoryPropertiesTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/ra/ConnectionFactoryPropertiesTest.java @@ -29,6 +29,7 @@ import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; import org.apache.activemq.artemis.ra.ActiveMQResourceAdapter; import org.apache.activemq.artemis.ra.ConnectionFactoryProperties; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; +import org.junit.Assert; import org.junit.Test; import static java.beans.Introspector.getBeanInfo; @@ -80,6 +81,7 @@ public class ConnectionFactoryPropertiesTest extends ActiveMQTestBase { @Test public void testCompareConnectionFactoryAndResourceAdapterProperties() throws Exception { SortedSet connectionFactoryProperties = findAllPropertyNames(ActiveMQConnectionFactory.class); + Assert.assertTrue(connectionFactoryProperties.contains("useTopologyForLoadBalancing")); connectionFactoryProperties.removeAll(UNSUPPORTED_CF_PROPERTIES); SortedSet raProperties = findAllPropertyNames(ActiveMQResourceAdapter.class); raProperties.removeAll(UNSUPPORTED_RA_PROPERTIES);