diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Create.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Create.java index aaaad9b622..da0ed7c9be 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Create.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Create.java @@ -283,6 +283,12 @@ public class Create extends InputAbstract { @Option(name = "--staticCluster", description = "Cluster node connectors list, separated by comma: Example \"tcp://server:61616,tcp://server2:61616,tcp://server3:61616\"") String staticNode; + @Option(name = "--support-advisory", description = "If set, the generated configuration will allow advisories for the openwire protocol") + boolean supportAdvisory = false; + + @Option(name = "--suppress-internal-management-objects", description = "If set, the generated configuration will register any advisory addresses/queues to management services for the openwire protocol") + boolean suppressInternalManagementObjects = false; + public String[] getStaticNodes() { if (staticNode == null) { return new String[0]; @@ -626,6 +632,8 @@ public class Create extends InputAbstract { } filters.put("${fsync}", String.valueOf(!noJournalSync)); filters.put("${default.port}", String.valueOf(defaultPort + portOffset)); + filters.put("${support-advisory}", Boolean.toString(supportAdvisory)); + filters.put("${suppress-internal-management-objects}", Boolean.toString(suppressInternalManagementObjects)); filters.put("${amqp.port}", String.valueOf(AMQP_PORT + portOffset)); filters.put("${stomp.port}", String.valueOf(STOMP_PORT + portOffset)); filters.put("${hq.port}", String.valueOf(HQ_PORT + portOffset)); diff --git a/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/broker.xml b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/broker.xml index dc48d94dec..78a9fd1093 100644 --- a/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/broker.xml +++ b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/broker.xml @@ -102,7 +102,7 @@ ${jdbc} - tcp://${host}:${default.port}?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;amqpMinLargeMessageSize=102400;protocols=CORE,AMQP,STOMP,HORNETQ,MQTT,OPENWIRE;useEpoll=true;amqpCredits=1000;amqpLowCredits=300;amqpDuplicateDetection=true + tcp://${host}:${default.port}?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;amqpMinLargeMessageSize=102400;protocols=CORE,AMQP,STOMP,HORNETQ,MQTT,OPENWIRE;useEpoll=true;amqpCredits=1000;amqpLowCredits=300;amqpDuplicateDetection=true;supportAdvisory=${support-advisory};suppressInternalManagementObjects=${suppress-internal-management-objects} ${amqp-acceptor}${stomp-acceptor}${hornetq-acceptor}${mqtt-acceptor} diff --git a/artemis-cli/src/test/java/org/apache/activemq/cli/test/ArtemisTest.java b/artemis-cli/src/test/java/org/apache/activemq/cli/test/ArtemisTest.java index d28edfccc8..325e83cb88 100644 --- a/artemis-cli/src/test/java/org/apache/activemq/cli/test/ArtemisTest.java +++ b/artemis-cli/src/test/java/org/apache/activemq/cli/test/ArtemisTest.java @@ -41,6 +41,7 @@ import java.nio.file.Files; import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; +import java.util.Map; import java.util.regex.Pattern; import org.apache.activemq.artemis.api.core.ActiveMQIllegalStateException; @@ -179,6 +180,51 @@ public class ArtemisTest extends CliTestBase { } } + @Test + public void testOpenwireSupportAdvisoryDisabledByDefault() throws Exception { + FileConfiguration configuration = createFileConfiguration("supportAdvisory", + "--force", "--silent", "--no-web", "--no-autotune"); + Map params = configuration.getAcceptorConfigurations() + .stream().filter(tc -> tc.getName().equals("artemis")).findFirst().get().getExtraParams(); + Assert.assertFalse(Boolean.parseBoolean(params.get("supportAdvisory").toString())); + Assert.assertFalse(Boolean.parseBoolean(params.get("suppressInternalManagementObjects").toString())); + } + + @Test + public void testOpenwireEnabledSupportAdvisory() throws Exception { + FileConfiguration configuration = createFileConfiguration("supportAdvisory", + "--force", "--silent", "--no-web", "--no-autotune", + "--support-advisory", "--suppress-internal-management-objects"); + Map params = configuration.getAcceptorConfigurations() + .stream().filter(tc -> tc.getName().equals("artemis")).findFirst().get().getExtraParams(); + Assert.assertTrue(Boolean.parseBoolean(params.get("supportAdvisory").toString())); + Assert.assertTrue(Boolean.parseBoolean(params.get("suppressInternalManagementObjects").toString())); + } + + + private FileConfiguration createFileConfiguration(String folder, String... createAdditionalArg) throws Exception { + File instanceFolder = temporaryFolder.newFolder(folder); + + setupAuth(instanceFolder); + + // This is usually set when run from the command line via artemis.profile + Run.setEmbedded(true); + final String[] createArgs = new String[2 + (createAdditionalArg == null ? 0 : createAdditionalArg.length)]; + createArgs[0] = "create"; + createArgs[1] = instanceFolder.getAbsolutePath(); + if (createAdditionalArg != null) { + System.arraycopy(createAdditionalArg, 0, createArgs, 2, createAdditionalArg.length); + } + Artemis.main(createArgs); + System.setProperty("artemis.instance", instanceFolder.getAbsolutePath()); + + FileConfiguration fc = new FileConfiguration(); + FileDeploymentManager deploymentManager = new FileDeploymentManager(new File(instanceFolder, "./etc/broker.xml").toURI().toString()); + deploymentManager.addDeployable(fc); + deploymentManager.readConfiguration(); + return fc; + } + @Test public void testWebConfig() throws Exception { setupAuth();