ARTEMIS-3533 - respect extra url parameters from federation connector-ref
This commit is contained in:
parent
cf85d35355
commit
3259791bbb
|
@ -17,6 +17,7 @@
|
|||
|
||||
package org.apache.activemq.artemis.core.server.federation;
|
||||
|
||||
import java.util.Map;
|
||||
import org.apache.activemq.artemis.api.core.ActiveMQSessionCreationException;
|
||||
import org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration;
|
||||
import org.apache.activemq.artemis.api.core.TransportConfiguration;
|
||||
|
@ -26,6 +27,7 @@ import org.apache.activemq.artemis.api.core.client.ServerLocator;
|
|||
import org.apache.activemq.artemis.core.config.Configuration;
|
||||
import org.apache.activemq.artemis.core.config.federation.FederationConnectionConfiguration;
|
||||
import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
|
||||
import org.apache.activemq.artemis.utils.uri.BeanSupport;
|
||||
|
||||
public class FederationConnection {
|
||||
|
||||
|
@ -39,6 +41,7 @@ public class FederationConnection {
|
|||
public FederationConnection(Configuration configuration, String name, FederationConnectionConfiguration config) {
|
||||
this.config = config;
|
||||
this.circuitBreakerTimeout = config.getCircuitBreakerTimeout();
|
||||
Map<String, Object> possibleLocatorParameters = null;
|
||||
if (config.getDiscoveryGroupName() != null) {
|
||||
DiscoveryGroupConfiguration discoveryGroupConfiguration = configuration.getDiscoveryGroupConfigurations().get(config.getDiscoveryGroupName());
|
||||
if (discoveryGroupConfiguration == null) {
|
||||
|
@ -67,6 +70,10 @@ public class FederationConnection {
|
|||
} else {
|
||||
serverLocator = ActiveMQClient.createServerLocatorWithoutHA(tcConfigs);
|
||||
}
|
||||
|
||||
if (tcConfigs.length > 0) {
|
||||
possibleLocatorParameters = tcConfigs[0].getExtraParams();
|
||||
}
|
||||
}
|
||||
|
||||
if (!config.isHA()) {
|
||||
|
@ -83,6 +90,14 @@ public class FederationConnection {
|
|||
serverLocator.setCallTimeout(config.getCallTimeout());
|
||||
serverLocator.setCallFailoverTimeout(config.getCallFailoverTimeout());
|
||||
|
||||
// let url parameters override
|
||||
if (possibleLocatorParameters != null) {
|
||||
try {
|
||||
BeanSupport.setData(serverLocator, possibleLocatorParameters);
|
||||
} catch (Exception ignoredAsErrorsVisibleViaBeanUtilsLogging) {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public synchronized void start() {
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
package org.apache.activemq.artemis.tests.integration.federation;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.activemq.artemis.api.core.TransportConfiguration;
|
||||
import org.apache.activemq.artemis.core.config.Configuration;
|
||||
|
@ -60,14 +59,8 @@ public class FederatedServerLocatorConfigTest extends FederatedTestBase {
|
|||
public void testFederatedAddressServerLocatorConfigFromUrl() throws Exception {
|
||||
String address = getName();
|
||||
|
||||
// we still won't pick up url params, restricted locator config is explicit
|
||||
// bundling getUseTopologyForLoadBalancing with HA=false is consistent with simplification
|
||||
String connectorName = "server1WithUrlParams";
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("host", "localhost");
|
||||
params.put("port", org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants.DEFAULT_PORT + 1);
|
||||
|
||||
getServer(0).getConfiguration().addConnectorConfiguration(connectorName, new TransportConfiguration(NETTY_CONNECTOR_FACTORY, params));
|
||||
getServer(0).getConfiguration().addConnectorConfiguration(connectorName, "tcp://localhost:" + (org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants.DEFAULT_PORT + 1) + "?ackBatchSize=100&consumerWindowSize=-1");
|
||||
|
||||
FederationConfiguration federationConfiguration0 = FederatedTestUtil.createAddressUpstreamFederationConfiguration("server1WithUrlParams", address, 2);
|
||||
for (FederationUpstreamConfiguration upstreamConfiguration : federationConfiguration0.getUpstreamConfigurations()) {
|
||||
|
@ -77,10 +70,12 @@ public class FederatedServerLocatorConfigTest extends FederatedTestBase {
|
|||
getServer(0).getFederationManager().deploy();
|
||||
|
||||
|
||||
// lets peek at the server locator
|
||||
// let's peek at the server locator
|
||||
Federation fed = getServer(0).getFederationManager().get(federationConfiguration0.getName());
|
||||
assertNotNull(fed);
|
||||
FederationUpstream federationUpstream = fed.get(connectorName);
|
||||
assertFalse(federationUpstream.getConnection().clientSessionFactory().getServerLocator().getUseTopologyForLoadBalancing());
|
||||
assertEquals(100, federationUpstream.getConnection().clientSessionFactory().getServerLocator().getAckBatchSize());
|
||||
assertEquals(-1, federationUpstream.getConnection().clientSessionFactory().getServerLocator().getConsumerWindowSize());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue