diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/logs/AuditLogger.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/logs/AuditLogger.java index 004a9a38c6..215c676bb2 100644 --- a/artemis-commons/src/main/java/org/apache/activemq/artemis/logs/AuditLogger.java +++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/logs/AuditLogger.java @@ -2710,4 +2710,10 @@ public interface AuditLogger { @LogMessage(id = 601776, value = "User {} is getting first message as json on target resource: {}", level = LogMessage.Level.INFO) void peekFirstMessageAsJSON(String user, Object source); + static void getBrokerPluginClassNames(Object source) { + BASE_LOGGER.getBrokerPluginClassNames(getCaller(), source); + } + + @LogMessage(id = 601777, value = "User {} is getting broker plugin class names on target resource: {}", level = LogMessage.Level.INFO) + void getBrokerPluginClassNames(String user, Object source); } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/ActiveMQServerControl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/ActiveMQServerControl.java index b8633e8c79..e671a2d2d9 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/ActiveMQServerControl.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/ActiveMQServerControl.java @@ -111,6 +111,10 @@ public interface ActiveMQServerControl { @Attribute(desc = "List of interceptors used by this server for outgoing messages") String[] getOutgoingInterceptorClassNames(); + + @Attribute(desc = "List of broker plugin class names used by this server") + String[] getBrokerPluginClassNames(); + /** * Returns whether this server is clustered. */ diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java index b50489994c..ee31b5186f 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java @@ -49,6 +49,7 @@ import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicReference; +import java.util.function.Function; import java.util.stream.Collectors; import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration; @@ -125,6 +126,7 @@ import org.apache.activemq.artemis.core.server.group.GroupingHandler; import org.apache.activemq.artemis.core.server.impl.Activation; import org.apache.activemq.artemis.core.server.impl.AddressInfo; import org.apache.activemq.artemis.core.server.impl.SharedNothingPrimaryActivation; +import org.apache.activemq.artemis.core.server.plugin.ActiveMQServerBasePlugin; import org.apache.activemq.artemis.core.server.replay.ReplayManager; import org.apache.activemq.artemis.core.settings.impl.AddressFullMessagePolicy; import org.apache.activemq.artemis.core.settings.impl.AddressSettings; @@ -351,6 +353,23 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active } } + @Override + public String[] getBrokerPluginClassNames() { + if (AuditLogger.isBaseLoggingEnabled()) { + AuditLogger.getBrokerPluginClassNames(this.server); + } + checkStarted(); + + clearIO(); + try { + return configuration.getBrokerPlugins().stream() + .map(brokerPlugin -> brokerPlugin.getClass().getCanonicalName() != null ? brokerPlugin.getClass().getCanonicalName() : brokerPlugin.getClass().getName()) + .toArray(String[]::new); + } finally { + blockOnIO(); + } + } + @Override public int getJournalPoolFiles() { if (AuditLogger.isBaseLoggingEnabled()) { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlTest.java index 3c50732111..085ea69938 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlTest.java @@ -44,6 +44,7 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; +import java.util.regex.Pattern; import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration; import org.apache.activemq.artemis.api.core.ActiveMQBuffer; @@ -100,6 +101,7 @@ import org.apache.activemq.artemis.core.server.ServerSession; import org.apache.activemq.artemis.core.server.ServiceComponent; import org.apache.activemq.artemis.core.server.impl.AddressInfo; import org.apache.activemq.artemis.core.server.impl.ServerLegacyProducersImpl; +import org.apache.activemq.artemis.core.server.plugin.ActiveMQServerPlugin; import org.apache.activemq.artemis.core.server.plugin.ActiveMQServerSessionPlugin; import org.apache.activemq.artemis.core.settings.impl.AddressFullMessagePolicy; import org.apache.activemq.artemis.core.settings.impl.AddressSettings; @@ -235,6 +237,28 @@ public class ActiveMQServerControlTest extends ManagementTestBase { Assert.assertTrue(serverControl.isActive()); } + @Test + public void testBrokerPluginClassNames() throws Exception { + ActiveMQServerControl serverControl = createManagementControl(); + + conf.registerBrokerPlugin(new TestBrokerPlugin()); + conf.registerBrokerPlugin(new ActiveMQServerPlugin() { + @Override + public void registered(ActiveMQServer server) { + } + }); + + Assert.assertEquals(2, conf.getBrokerPlugins().size()); + Assert.assertEquals(2, serverControl.getBrokerPluginClassNames().length); + Assert.assertEquals( + "org.apache.activemq.artemis.tests.integration.management.ActiveMQServerControlTest.TestBrokerPlugin", + serverControl.getBrokerPluginClassNames()[0]); + Assert.assertTrue(Pattern.matches( + "org.apache.activemq.artemis.tests.integration.management.ActiveMQServerControlTest\\$\\d+$", + serverControl.getBrokerPluginClassNames()[1] + )); + } + @Test public void testSecurityCacheSizes() throws Exception { ActiveMQServerControl serverControl = createManagementControl(); @@ -6190,5 +6214,10 @@ public class ActiveMQServerControlTest extends ManagementTestBase { session.commit(); } + private static class TestBrokerPlugin implements ActiveMQServerPlugin { + @Override + public void registered(ActiveMQServer server) { + } + } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlUsingCoreTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlUsingCoreTest.java index 44c72ed32f..397fdf62a8 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlUsingCoreTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlUsingCoreTest.java @@ -540,6 +540,11 @@ public class ActiveMQServerControlUsingCoreTest extends ActiveMQServerControlTes return (String[]) proxy.retrieveAttributeValue("outgoingInterceptorClassNames", String.class); } + @Override + public String[] getBrokerPluginClassNames() { + return (String[]) proxy.retrieveAttributeValue("brokerPluginClassNames", String.class); + } + @Override public String getJournalDirectory() { return (String) proxy.retrieveAttributeValue("journalDirectory");