简体   繁体   中英

How Do I monitor connection pool programmatically in Jboss?

I am working on project where there is a need to monitor connection pool usage like ActiveCount, AvailableCount, MaxUsedCount. I am struggling to find something useful. I know that connection pool craetes an MBean and binds it with the underlying available JMX server.This MBean will hold all the information about the connection pool. I want have access to this MBean so that I can access all attributes inside it.

However I know if I execute jboss-cli.sh in linux environment and execute

/subsystem=datasources/data-source=ExampleDS/statistics=pool:read-resource(include-runtime=true)

I will get below output

{
    "outcome" => "success",
    "result" => {
        "ActiveCount" => "0",
        "AvailableCount" => "20",
        "AverageBlockingTime" => "0",
        "AverageCreationTime" => "0",
        "CreatedCount" => "0",
        "DestroyedCount" => "0",
        "MaxCreationTime" => "0",
        "MaxUsedCount" => "0",
        "MaxWaitTime" => "0",
        "TimedOut" => "0",
        "TotalBlockingTime" => "0",
        "TotalCreationTime" => "0"
    }
} 

Now same thing I wanted to achieve using programmatically. I am not sure how do I do this. Because I will run some program which will run at specific time interval and log connection data like ActiveCount, AvailableCount, MaxUsedCount which can be used further.

NOTE: I am using wilfly-9.0.1.Final

Please Guide.

You can use CLI to get these statistics. To do so execute it from code as terminal command and parse result.

Also there is The HTTP management API and The native management API

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM