From 03d1a9df8b4baddde857fc5c55853202a029098e Mon Sep 17 00:00:00 2001 From: jbertram Date: Tue, 5 May 2015 10:39:36 -0500 Subject: [PATCH] ACTIVEMQ6-96 ensure connectionsAllowed work on invm acceptor URI --- .../artemis/uri/InVMServerLocatorSchema.java | 2 +- .../uri/InVMTransportConfigurationSchema.java | 13 +++++++++++-- .../org/apache/activemq/artemis/uri/InVMSchema.java | 2 +- .../core/config/impl/FileConfigurationTest.java | 3 +++ .../resources/ConfigurationTest-full-config.xml | 4 ++-- 5 files changed, 18 insertions(+), 6 deletions(-) diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/InVMServerLocatorSchema.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/InVMServerLocatorSchema.java index cb57306f09..d828c8dd1e 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/InVMServerLocatorSchema.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/InVMServerLocatorSchema.java @@ -37,7 +37,7 @@ public class InVMServerLocatorSchema extends AbstractServerLocatorSchema @Override protected ServerLocator internalNewObject(URI uri, Map query, String name) throws Exception { - TransportConfiguration tc = InVMTransportConfigurationSchema.createTransportConfiguration(uri, name, "org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory"); + TransportConfiguration tc = InVMTransportConfigurationSchema.createTransportConfiguration(uri, query, name, "org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory"); ServerLocator factory = ActiveMQClient.createServerLocatorWithoutHA(tc); return URISchema.setData(uri, factory, query); } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/InVMTransportConfigurationSchema.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/InVMTransportConfigurationSchema.java index a9ea8bc860..722a89dcb7 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/InVMTransportConfigurationSchema.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/uri/InVMTransportConfigurationSchema.java @@ -27,6 +27,11 @@ import java.util.Map; public class InVMTransportConfigurationSchema extends AbstractTransportConfigurationSchema { + /* This is the same as org.apache.activemq.artemis.core.remoting.impl.invm.TransportConstants.CONNECTIONS_ALLOWED, + * but this Maven module can't see that class. + */ + public static final String CONNECTIONS_ALLOWED = "connectionsAllowed"; + @Override public String getSchemaName() { @@ -37,7 +42,7 @@ public class InVMTransportConfigurationSchema extends AbstractTransportConfigura protected List internalNewObject(URI uri, Map query, String name) throws Exception { List configurations = new ArrayList<>(); - configurations.add(createTransportConfiguration(uri, name, getFactoryName())); + configurations.add(createTransportConfiguration(uri, query, name, getFactoryName())); return configurations; } @@ -52,10 +57,14 @@ public class InVMTransportConfigurationSchema extends AbstractTransportConfigura return "org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory"; } - public static TransportConfiguration createTransportConfiguration(URI uri, String name, String factoryName) + public static TransportConfiguration createTransportConfiguration(URI uri, Map query, String name, String factoryName) { Map inVmTransportConfig = new HashMap<>(); inVmTransportConfig.put("serverId", uri.getHost()); + if (query.containsKey(CONNECTIONS_ALLOWED)) + { + inVmTransportConfig.put(CONNECTIONS_ALLOWED, query.get(CONNECTIONS_ALLOWED)); + } return new TransportConfiguration(factoryName, inVmTransportConfig, name); } } diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/InVMSchema.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/InVMSchema.java index 366d7d0871..f35366f27f 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/InVMSchema.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/InVMSchema.java @@ -37,7 +37,7 @@ public class InVMSchema extends AbstractCFSchema JMSConnectionOptions options = newConectionOptions(uri, query); ActiveMQConnectionFactory factory = ActiveMQJMSClient.createConnectionFactoryWithoutHA(options.getFactoryTypeEnum(), - InVMTransportConfigurationSchema.createTransportConfiguration(uri, name, "org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory")); + InVMTransportConfigurationSchema.createTransportConfiguration(uri, query, name, "org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory")); return setData(uri, factory, query); } diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationTest.java index 6f930680b0..4a9ed436fd 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationTest.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationTest.java @@ -36,6 +36,7 @@ import org.apache.activemq.artemis.core.config.DivertConfiguration; import org.apache.activemq.artemis.core.config.FileDeploymentManager; import org.apache.activemq.artemis.core.config.HAPolicyConfiguration; import org.apache.activemq.artemis.core.config.ha.LiveOnlyPolicyConfiguration; +import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants; import org.apache.activemq.artemis.core.security.Role; import org.apache.activemq.artemis.core.server.JournalType; import org.apache.activemq.artemis.core.settings.impl.SlowConsumerPolicy; @@ -130,12 +131,14 @@ public class FileConfigurationTest extends ConfigurationImplTest { Assert.assertEquals("456", ac.getParams().get("tcpNoDelay")); Assert.assertEquals("44", ac.getParams().get("connectionTtl")); + Assert.assertEquals("92", ac.getParams().get(TransportConstants.CONNECTIONS_ALLOWED)); } else { Assert.assertEquals("org.apache.activemq.artemis.core.remoting.impl.invm.InVMAcceptorFactory", ac.getFactoryClassName()); Assert.assertEquals("0", ac.getParams().get("serverId")); + Assert.assertEquals("87", ac.getParams().get(org.apache.activemq.artemis.core.remoting.impl.invm.TransportConstants.CONNECTIONS_ALLOWED)); } } diff --git a/artemis-server/src/test/resources/ConfigurationTest-full-config.xml b/artemis-server/src/test/resources/ConfigurationTest-full-config.xml index 75f636c91c..0f81b759e7 100644 --- a/artemis-server/src/test/resources/ConfigurationTest-full-config.xml +++ b/artemis-server/src/test/resources/ConfigurationTest-full-config.xml @@ -64,8 +64,8 @@ vm://5 - tcp://0.0.0.0:61616?tcpNoDelay=456;connectionTtl=44 - vm://0?e1=z1;e2=567 + tcp://0.0.0.0:61616?tcpNoDelay=456;connectionTtl=44;connectionsAllowed=92 + vm://0?e1=z1;e2=567;connectionsAllowed=87