1

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.

mahendra kawde
  • 855
  • 4
  • 25
  • 44

2 Answers2

0

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.

DaImmi
  • 121
  • 5
  • Thanks for your response. I would have configured datasource in standalone.xml but there is not single datasource. I am dealing with almost more than 200 datasource files. So I feel configuring datasource in -ds.xml deployed in /deployment folder would be good option. Another advantage of having datasource placed in -ds.xml file is that I don't have to restart server everytime when I add new datasource. But in case of standalone.xml I have to restart server if I add any new datasource. – mahendra kawde Jun 15 '16 at 12:42
  • Have a look at my update. You can use the JMX MBean in combination with jolokia and monitor it on a proper monitoring system. – DaImmi Jun 15 '16 at 13:13
0

Please try this with jboss-cli:

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

Youcef LAIDANI
  • 55,661
  • 15
  • 90
  • 140
Gaur
  • 1
  • 7