Advertise with us

Our eBooks

Monitoring the EJB container using the CLI

In this tutorial we will learn how to gather EJB 3 container statistics from JBoss AS 7 / JBoss EAP using the Command Line Interface. 

So you have deployed your EJBs and you want to know if your configuration is able to meet your requests. Now worry, using the Command Line Interface it's just a minute away from you!
Start the CLI using:

./jboss-cli.sh

(Or using the Windows equivalent batch).
Then you need to point to the application which contains EJB resources. Supposing you want to monitor an application named cdi-demo.war which contains the Stateless EJB ServiceBean. Here's how to construct the CLI query:

[standalone@localhost:9999 /] /deployment=cdi-demo.war/subsystem=ejb3/stateless-session-bean=ServiceBean:read-resource(include-runtime=true)

{
"outcome" => "success",
"result" => {
"component-class-name" => "ServiceBean",
"declared-roles" => [],
"execution-time" => 0L,
"invocations" => 0L,
"methods" => {},
"peak-concurrent-invocations" => 0L,
"pool-available-count" => 20,
"pool-create-count" => 3,
"pool-current-size" => 0,
"pool-max-size" => 20,
"pool-name" => "slsb-strict-max-pool",
"pool-remove-count" => 3,
"run-as-role" => undefined,
"security-domain" => "other",
"timers" => [],
"wait-time" => 0L
}
}

Some of the metrics are not traced(notably methods executed, execution time and invocations), however you can get an insight on the available Beans in the pool, the number of EJB created and removed from the pool.
The same technique can be used to monitor other resources contained in the application, for example the statistics of a Servlet. As the application is a JSF based application we can gather statistics on the Faces Servlet this way:

[standalone@localhost:9999 /] /deployment=cdi-demo.war/subsystem=web/servlet=Faces\ Servlet:read-resource(include-runtime=true)
{
"outcome" => "success",
"result" => {
"load-time" => 0L,
"maxTime" => 36L,
"min-time" => 0L,
"processingTime" => 3410L,
"requestCount" => 6,
"servlet-class" => "javax.faces.webapp.FacesServlet",
"servlet-name" => "Faces Servlet"
}
}

© 2021 mastertheboss.com. All Rights Reserved.

Please publish modules in offcanvas position.