From e6d316ef4266c6620247dcfa04565738422b8d7b Mon Sep 17 00:00:00 2001 From: AM-19 Date: Sun, 31 Mar 2024 23:45:00 +0530 Subject: [PATCH] [AMQ-9447] Added Logic to check underlying transport connector limits --- .../activemq/broker/jmx/HealthView.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/HealthView.java b/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/HealthView.java index 47a153ed94..4ce82172b7 100644 --- a/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/HealthView.java +++ b/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/HealthView.java @@ -29,8 +29,10 @@ import javax.management.openmbean.TabularDataSupport; import javax.management.openmbean.TabularType; import org.apache.activemq.broker.BrokerService; +import org.apache.activemq.broker.TransportConnector; import org.apache.activemq.broker.scheduler.JobSchedulerStore; import org.apache.activemq.store.PersistenceAdapter; +import org.apache.activemq.transport.tcp.TcpTransportServer; import org.apache.activemq.usage.SystemUsage; public class HealthView implements HealthViewMBean { @@ -167,6 +169,25 @@ public class HealthView implements HealthViewMBean { } } + /** + * Check The Transport Connector limits + */ + + if (brokerService != null && !brokerService.getTransportConnectors().isEmpty()) { + for(TransportConnector tc: brokerService.getTransportConnectors()) { + if(tc.getServer() instanceof TcpTransportServer) { + int connectionUsage = (int) (((TcpTransportServer)tc.getServer()).getCurrentTransportCount().get() * 100 ) / ((TcpTransportServer)tc.getServer()).getMaximumConnections(); + if(((TcpTransportServer)tc.getServer()).getCurrentTransportCount().get() >= ((TcpTransportServer)tc.getServer()).getMaximumConnections()) { + String message = "Exceeded the maximum number of allowed client connections: " + ((TcpTransportServer)tc.getServer()).getMaximumConnections(); + answer.add(new HealthStatus("org.apache.activemq.transport.tcp.TcpTransportServer", "ERROR", message, tc.getName())); + } else if(connectionUsage > 90) { + String message = "The Current connection count is within " + connectionUsage + "% of MaximumConnections limit"; + answer.add(new HealthStatus("org.apache.activemq.transport.tcp.TcpTransportServer", "WARNING", message, tc.getName())); + } + } + } + } + StringBuilder currentState = new StringBuilder(); if (answer != null && !answer.isEmpty()) { currentState.append("Getting Worried {");