diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/TransportConfiguration.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/TransportConfiguration.java index 84d7a8a881..5a823a8369 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/TransportConfiguration.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/TransportConfiguration.java @@ -92,6 +92,7 @@ public class TransportConfiguration implements Serializable { */ public TransportConfiguration() { this.params = new HashMap<>(); + this.extraProps = new HashMap<>(); } /** @@ -103,7 +104,7 @@ public class TransportConfiguration implements Serializable { * @param name The name of this TransportConfiguration */ public TransportConfiguration(final String className, final Map params, final String name) { - this(className, params, name, null); + this(className, params, name, new HashMap<>()); } /** diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImplTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImplTest.java index aed4d3a78d..87d0cd2060 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImplTest.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImplTest.java @@ -40,6 +40,7 @@ import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.core.config.Configuration; +import org.apache.activemq.artemis.core.config.ConfigurationUtils; import org.apache.activemq.artemis.core.config.amqpBrokerConnectivity.AMQPBrokerConnectConfiguration; import org.apache.activemq.artemis.core.config.amqpBrokerConnectivity.AMQPBrokerConnectionAddressType; import org.apache.activemq.artemis.core.config.amqpBrokerConnectivity.AMQPBrokerConnectionElement; @@ -922,6 +923,38 @@ public class ConfigurationImplTest extends ActiveMQTestBase { } + @Test + public void testAcceptorViaProperties() throws Throwable { + ConfigurationImpl configuration = new ConfigurationImpl(); + + configuration.getAcceptorConfigurations().add(ConfigurationUtils.parseAcceptorURI( + "artemis", "tcp://0.0.0.0:61616?protocols=CORE,AMQP,STOMP,HORNETQ,MQTT,OPENWIRE;supportAdvisory=false;suppressInternalManagementObjects=false").get(0)); + + Properties properties = new Properties(); + + properties.put("acceptorConfigurations.artemis.extraParams.supportAdvisory", "true"); + properties.put("acceptorConfigurations.new.extraParams.supportAdvisory", "true"); + + configuration.parsePrefixedProperties(properties, null); + + Assert.assertEquals(2, configuration.getAcceptorConfigurations().size()); + + TransportConfiguration artemisTransportConfiguration = configuration.getAcceptorConfigurations().stream().filter( + transportConfiguration -> transportConfiguration.getName().equals("artemis")).findFirst().get(); + Assert.assertTrue(artemisTransportConfiguration.getParams().containsKey("protocols")); + Assert.assertEquals("CORE,AMQP,STOMP,HORNETQ,MQTT,OPENWIRE", artemisTransportConfiguration.getParams().get("protocols")); + Assert.assertTrue(artemisTransportConfiguration.getExtraParams().containsKey("supportAdvisory")); + Assert.assertEquals("true", artemisTransportConfiguration.getExtraParams().get("supportAdvisory")); + Assert.assertTrue(artemisTransportConfiguration.getExtraParams().containsKey("suppressInternalManagementObjects")); + Assert.assertEquals("false", artemisTransportConfiguration.getExtraParams().get("suppressInternalManagementObjects")); + + TransportConfiguration newTransportConfiguration = configuration.getAcceptorConfigurations().stream().filter( + transportConfiguration -> transportConfiguration.getName().equals("new")).findFirst().get(); + Assert.assertTrue(newTransportConfiguration.getExtraParams().containsKey("supportAdvisory")); + Assert.assertEquals("true", newTransportConfiguration.getExtraParams().get("supportAdvisory")); + } + + @Test public void testAddressSettingsViaProperties() throws Throwable { ConfigurationImpl configuration = new ConfigurationImpl();