From c4d2ba88e685d2f1d5e1eb2d517013000e9298a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Albertas=20Vy=C5=A1niauskas?= Date: Sun, 14 Sep 2025 09:40:25 +0300 Subject: [PATCH 1/3] [AMQ-9769] Add name property to connector interface and MBean. --- .../src/main/java/org/apache/activemq/broker/Connector.java | 5 +++++ .../java/org/apache/activemq/broker/jmx/ConnectorView.java | 5 +++++ .../org/apache/activemq/broker/jmx/ConnectorViewMBean.java | 3 +++ 3 files changed, 13 insertions(+) diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/Connector.java b/activemq-broker/src/main/java/org/apache/activemq/broker/Connector.java index 314a0925715..7d9fcc8f724 100644 --- a/activemq-broker/src/main/java/org/apache/activemq/broker/Connector.java +++ b/activemq-broker/src/main/java/org/apache/activemq/broker/Connector.java @@ -86,4 +86,9 @@ public interface Connector extends Service { * @return true if connector is started */ public boolean isStarted(); + + /** + * @return connector name + */ + public String getName(); } diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ConnectorView.java b/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ConnectorView.java index 4493e06a96a..5786172be86 100644 --- a/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ConnectorView.java +++ b/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ConnectorView.java @@ -151,4 +151,9 @@ public boolean isAutoStart() { public boolean isStarted() { return this.connector.isStarted(); } + + @Override + public String getName() { + return this.connector.getName(); + } } diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ConnectorViewMBean.java b/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ConnectorViewMBean.java index e089447c567..c2f99a27548 100644 --- a/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ConnectorViewMBean.java +++ b/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ConnectorViewMBean.java @@ -101,4 +101,7 @@ public interface ConnectorViewMBean extends Service { */ @MBeanInfo("Connector started") boolean isStarted(); + + @MBeanInfo("Connector name") + String getName(); } From d2f94889eb4d898f409215c2c1e52e0b37acb2bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Albertas=20Vy=C5=A1niauskas?= Date: Sun, 14 Sep 2025 09:42:22 +0300 Subject: [PATCH 2/3] [AMQ-9769] Use connector name property in web console. --- .../WEB-INF/tags/jms/forEachConnection.tag | 5 ++--- .../src/main/webapp/connections.jsp | 6 +++--- .../org/apache/activemq/web/BrokerFacade.java | 9 ++++----- .../activemq/web/BrokerFacadeSupport.java | 20 ++++++++----------- 4 files changed, 17 insertions(+), 23 deletions(-) diff --git a/activemq-web-console/src/main/webapp/WEB-INF/tags/jms/forEachConnection.tag b/activemq-web-console/src/main/webapp/WEB-INF/tags/jms/forEachConnection.tag index 6b6af7e3a20..dfa333ca672 100644 --- a/activemq-web-console/src/main/webapp/WEB-INF/tags/jms/forEachConnection.tag +++ b/activemq-web-console/src/main/webapp/WEB-INF/tags/jms/forEachConnection.tag @@ -23,9 +23,8 @@ <% Iterator it = broker.getConnections(connectorName).iterator(); while (it.hasNext()) { - String conName = (String) it.next(); - ConnectionViewMBean con = broker.getConnection(conName); - request.setAttribute(connectionName, conName); + ConnectionViewMBean con = (ConnectionViewMBean) it.next(); + request.setAttribute(connectionName, con.getClientId()); request.setAttribute(connection, con); %> diff --git a/activemq-web-console/src/main/webapp/connections.jsp b/activemq-web-console/src/main/webapp/connections.jsp index be280edeed1..fe75bce9e7b 100644 --- a/activemq-web-console/src/main/webapp/connections.jsp +++ b/activemq-web-console/src/main/webapp/connections.jsp @@ -28,8 +28,8 @@

Connections

- -

Connector

+ +

Connector

@@ -41,7 +41,7 @@ - diff --git a/activemq-web/src/main/java/org/apache/activemq/web/BrokerFacade.java b/activemq-web/src/main/java/org/apache/activemq/web/BrokerFacade.java index 720ebcbb16d..5f3646a82e3 100644 --- a/activemq-web/src/main/java/org/apache/activemq/web/BrokerFacade.java +++ b/activemq-web/src/main/java/org/apache/activemq/web/BrokerFacade.java @@ -134,12 +134,12 @@ Collection getInactiveDurableTopicSubscribers() throws Exception; /** - * The names of all transport connectors of the broker (f.e. openwire, ssl) + * All transport connectors of the broker (f.e. openwire, ssl) * * @return not null * @throws Exception */ - Collection getConnectors() throws Exception; + Collection getConnectors() throws Exception; /** * A transport connectors. @@ -160,8 +160,7 @@ Collection getInactiveDurableTopicSubscribers() Collection getConnections() throws Exception; /** - * The names of all connections to a specific transport connectors of the - * broker. + * All connections to a specific transport connectors of the broker. * * @see #getConnection(String) * @param connectorName @@ -169,7 +168,7 @@ Collection getInactiveDurableTopicSubscribers() * @return not null * @throws Exception */ - Collection getConnections(String connectorName) throws Exception; + Collection getConnections(String connectorName) throws Exception; /** * A specific connection to the broker. diff --git a/activemq-web/src/main/java/org/apache/activemq/web/BrokerFacadeSupport.java b/activemq-web/src/main/java/org/apache/activemq/web/BrokerFacadeSupport.java index 5f8d7df610c..09e1b7cb27d 100644 --- a/activemq-web/src/main/java/org/apache/activemq/web/BrokerFacadeSupport.java +++ b/activemq-web/src/main/java/org/apache/activemq/web/BrokerFacadeSupport.java @@ -169,16 +169,13 @@ public Collection getConnections() throws Exception { @Override @SuppressWarnings("unchecked") - public Collection getConnections(String connectorName) throws Exception { + public Collection getConnections(String connectorName) throws Exception { String brokerName = getBrokerName(); ObjectName query = new ObjectName("org.apache.activemq:type=Broker,brokerName=" + brokerName - + ",connector=clientConnectors,connectorName=" + connectorName + ",connectionViewType=clientId" + ",connectionName=*"); Set queryResult = queryNames(query, null); - Collection result = new ArrayList(queryResult.size()); - for (ObjectName on : queryResult) { - String name = StringUtils.replace(on.getKeyProperty("connectionName"), "_", ":"); - result.add(name); - } - return result; + + ",connector=clientConnectors,connectorName=" + connectorName + ",connectionViewType=clientId,connectionName=*"); + Set queryResult = queryNames(query, null); + return getManagedObjects(queryResult.toArray(new ObjectName[queryResult.size()]), + ConnectionViewMBean.class); } @Override @@ -198,14 +195,13 @@ public ConnectionViewMBean getConnection(String connectionName) throws Exception @Override @SuppressWarnings("unchecked") - public Collection getConnectors() throws Exception { + public Collection getConnectors() throws Exception { String brokerName = getBrokerName(); ObjectName query = new ObjectName("org.apache.activemq:type=Broker,brokerName=" + brokerName + ",connector=clientConnectors,connectorName=*"); Set queryResult = queryNames(query, null); Collection result = new ArrayList(queryResult.size()); - for (ObjectName on : queryResult) - result.add(on.getKeyProperty("connectorName")); - return result; + return getManagedObjects(queryResult.toArray(new ObjectName[queryResult.size()]), + ConnectorViewMBean.class); } @Override From df94e5743179eca513b07e0d8b0a5bf342e883dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Albertas=20Vy=C5=A1niauskas?= Date: Tue, 30 Sep 2025 16:21:22 +0300 Subject: [PATCH 3/3] Add getConnectionId() to ConnectionViewMBeanAdd. --- .../org/apache/activemq/broker/jmx/ConnectionView.java | 1 + .../apache/activemq/broker/jmx/ConnectionViewMBean.java | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ConnectionView.java b/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ConnectionView.java index 593c4f999e3..6106471821a 100644 --- a/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ConnectionView.java +++ b/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ConnectionView.java @@ -105,6 +105,7 @@ public String getClientId() { return connection.getConnectionId(); } + @Override public String getConnectionId() { return connection.getConnectionId(); } diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ConnectionViewMBean.java b/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ConnectionViewMBean.java index 77eb188f5d4..6146fa92bf9 100644 --- a/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ConnectionViewMBean.java +++ b/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ConnectionViewMBean.java @@ -68,6 +68,14 @@ public interface ConnectionViewMBean extends Service { @MBeanInfo("client id for this connection") String getClientId(); + /** + * Returns the identifier for this connection + * + * @return the identifier for this connection + */ + @MBeanInfo("ID for this connection") + String getConnectionId(); + /** * Returns the number of messages to be dispatched to this connection * @return the number of messages pending dispatch