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

    How to get connection pool size programmatically in JBoss?

    mahendra kawde Newbie

      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?
          Miroslav Novak Master

          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("", 9990, null, null, 5000);
          ModelNode model = new ModelNode();
          model.get(ClientConstants.OP_ADDR).add("subsystem", "ejb3");
          model.get(ClientConstants.OP_ADDR).add("strict-max-bean-instance-pool", "slsb-strict-max-pool");
          ModelNode result = modelControllerClient.execute(model);
          ModelNode modelwrite = new ModelNode();
          modelwrite.get(ClientConstants.OP_ADDR).add("subsystem", "ejb3");
          modelwrite.get(ClientConstants.OP_ADDR).add("strict-max-bean-instance-pool", "slsb-strict-max-pool");
          ModelNode result2 = modelControllerClient.execute(modelwrite);


          You will need maven dependencies:






          and probably something more :-)