1
votes

Is there any way to determine database connection pool size. I want to find out min pool size, max pool size.

The reason is as follows:

  1. My application is running on Wildfly-9.0.1.Final.
  2. I have configure datasource in -ds.xml file.
  3. I have so many clients and for each one there is -ds.xml file.
  4. In each file I have specified max-pool-size = 30.

But for some clients this size(30) happens to be small as more and more user tries to get connection from pool concurrently. Then in that case I need to increase max-pool-size to higher number. I want something like that will help me to fetch these parameters and then based on that I will perform some logic. Like if pool-size have reached to 25/30 then it will trigger email as an alert so that developer can increase its pool size. This way it will be helpful to avoid problems that client do faces when he could not get connection when all are being aquired.

Is there any way to access these connection pool parameters programatically.

2

2 Answers

0
votes

Well there are multiple ways. If your datasource would be configured in the standalone.xml you could easily achieve your goal

via the CLI command (have a look here if you're not familiar with the CLI)

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

through JMX by reading the following MBean

jboss.as:subsystem=datasources,data-source=ExampleDS,statistics=pool

Beware: In both cases ExampleDS has to be replaced with your actual datasource name.

Update

If you directly drop a -ds.xml into the deployments directory you can read the statistics like this:

/deployment=my-ds.xml/subsystem=datasources/data-source=java\:jboss\/my\/jndiName\/for\/DeployedDS/statistics=pool:read-resource(include-runtime=true)

or

jboss.as:deployment=my-ds.xml,subsystem=datasources,data-source="java:jboss/my/jndiName/for/DeployedDS",statistics=pool

Note that in any case you will have to enable these statistics first before you can acces any useful information with the methods shown above. These statistics might be a performance drawback. You can enable these statistics for example via CLI:

/deployment=my-ds.xml/subsystem=datasources/data-source=java\:jboss\/my\/jndiName\/for\/DeployedDS/statistics=pool:write-attribute(name=statistics-enabled, value=true)

When working with WildFly I'd generally recommend to configure datasources in the standalone.xml - it's way better supported.

0
votes

Please try this with jboss-cli:

[standalone@localhost:9999 /] /subsystem=datasources/data-source=ExampleDS/statistics=pool:read-resource(include-runtime=true)