Description
A slow performance was detected during the JMX request using Mbeans.
When a request is doing to get ThreadCount information about consecutive 1000 times, the outcome is about 10 msec.
Using the same code to get ActiveCount in datasource for continuous 1000 times, the outcome is about 3000msec.
Is this a bug or a normal behavior in JMX calls?
The code used is a JSP below:
<%@ page import="javax.management.MBeanServer" %>
<%@ page import="java.lang.management.ManagementFactory" %><%@ page import="javax.management.ObjectName"%>
<%@ page trimDirectiveWhitespaces="true" %>
<%@ page contentType="text/plain;charset=UTF-8" %>
<%!
static void getAttribute(JspWriter out, MBeanServer mbeanServer, String objectName, String attributeName, int loops) throws Exception {
long timestamp = System.currentTimeMillis();
for (int i = 0; i < loops; i++)
{ mbeanServer.getAttribute(new ObjectName(objectName), attributeName); } out.println("Read '" + objectName + " / " + attributeName + "' " + loops + " times in " + (System.currentTimeMillis() - timestamp) + " msec");
}
%>
<%
int loops = 1000;
MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
getAttribute(out, mbeanServer, "java.lang:type=Threading", "ThreadCount", loops);
getAttribute(out, mbeanServer, "jboss.as:subsystem=datasources,data-source=ExampleDS,statistics=pool", "ActiveCount", loops);
%>