1 Reply Latest reply on Jun 28, 2016 8:51 AM by mnovak

    How to get connection pool size programmatically in JBoss?

    mahendrakawde

      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.
      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.

        • 1. Re: How to get connection pool size programmatically in JBoss?
          mnovak

          Yes, it's possible to do that programatically but it will probably need to reload server to take effect. I'm not sure which pool you would like to increase so take this just as an example:

           

          ModelControllerClient modelControllerClient = ModelControllerClient.Factory.create("127.0.0.1", 9990, null, null, 5000);
          ModelNode model = new ModelNode();
          model.get(ClientConstants.OP).set("read-attribute");
          model.get(ClientConstants.OP_ADDR).add("subsystem", "ejb3");
          model.get(ClientConstants.OP_ADDR).add("strict-max-bean-instance-pool", "slsb-strict-max-pool");
          model.get("name").set("max-pool-size");
          ModelNode result = modelControllerClient.execute(model);
          System.out.println(result);
          
          ModelNode modelwrite = new ModelNode();
          modelwrite.get(ClientConstants.OP).set("write-attribute");
          modelwrite.get(ClientConstants.OP_ADDR).add("subsystem", "ejb3");
          modelwrite.get(ClientConstants.OP_ADDR).add("strict-max-bean-instance-pool", "slsb-strict-max-pool");
          modelwrite.get("name").set("max-pool-size");
          modelwrite.get("value").set(30);
          ModelNode result2 = modelControllerClient.execute(modelwrite);
          System.out.println(result2);
          modelControllerClient.close();
          

           

          You will need maven dependencies:

          <dependency>

             <groupId>org.wildfly.core</groupId>

             <artifactId>wildfly-controller-client</artifactId>

             <version>${version.org.wildfly.core.wildfly-core-everything}</version>

          </dependency>


          and probably something more :-)