9 Replies Latest reply on Nov 16, 2004 5:57 AM by dimitris

    Retrieve listing of connection pools

    bbalmer

      I am having trouble dynamically finding all of the different connection pools that I have set up. To get connection information I currently have each pool name hard-coded. I would like to do a query to get all of the different pools but my query ALWAYS returns no value.

      Here is a snipit of how I am querying:

      ObjectName scope = new ObjectName("jboss.jca:service=ManagedConnectionPool");

      QueryExp exp = Query.initialSubString(Query.attr("Name"), Query.value("jdbc"));

      Set set = server.queryNames(scope, exp);

      My set size is always empty.

      Currently I fully name the ObjectName with:
      jboss.jca:service=ManagedConnectionPool,name=jdbc/central

      I am able to get all information on the pool.

      Any help with querying would be GREATLY appreciated.

      Thanks.


        • 1. Re: Retrieve listing of connection pools
          diripu

          Could anyone help me in this JCAStats ?? Its urgent.

          Thanks in advance.

          • 2. Re: Retrieve listing of connection pools
            dimitris

            If your MBean naming is consistent, you don't need to include a QueryExp in the call to QueryNames (just pass null as a second argument). QueryExp really refers to the actual attribute values of MBeans

            Then use a appropriate ObjectName pattern, eg:

            "jboss.jca:service=ManagedConnectionPool,*"

            will get you all ManagedConnectionPools, under domain jboss.jca

            Alter your connection MBean names if necessary

            • 3. Re: Retrieve listing of connection pools
              bbalmer

              Thanks for your quick reply. I changed my code to:

              ObjectName scope = new ObjectName("jboss.jca:service=ManagedConnectionPool,*");

              QueryExp exp = Query.initialSubString(Query.attr("Name"), null);

              Set set = server.queryNames(scope, exp);
              log.info("Found " + set.size() + " pools");

              Iterator it = set.iterator();

              while(it.hasNext())
              log.info(it.next());

              And it still found 0 results. Am I still doing something wrong? Should I not be using Query.initialSubString?

              • 4. Re: Retrieve listing of connection pools
                dimitris

                You do NOT need the QueryExp:

                ObjectName scope = new ObjectName("jboss.jca:service=ManagedConnectionPool,*");
                
                Set set = server.queryNames(scope, null);
                 log.info("Found " + set.size() + " pools");
                
                Iterator it = set.iterator();
                
                while(it.hasNext())
                 log.info(it.next());
                


                • 5. Re: Retrieve listing of connection pools
                  bbalmer

                  Sorry for the misunderstanding.

                  This works exactly as I had hoped. Thank you for your help.

                  • 6. Re: Retrieve listing of connection pools
                    diripu


                    What is the difference between the follwing MBeans ? Does "JmsXA" is
                    the connectionpool name?

                    "jboss.jca:name=JmsXA,service=ManagedConnectionPool "

                    "jboss.management.local:J2EEServer=Local,ResourceAdapter=JMS Adapter,j2eeType=JCAResource,name=JmsXA"


                    • 7. Re: Retrieve listing of connection pools
                      dimitris

                      MBeans in the "jboss.management.local" domain are JSR77 compliant "proxy" objects, modelling in a standard way some management aspect of the server. So, for example, if you deploy an .ear or a .rar you'll see a number of them being created.

                      • 8. Re: Retrieve listing of connection pools
                        diripu

                        Could anyone help me in this JCAStats ?? Its urgent.

                        Thanks in advance.

                        • 9. Re: Retrieve listing of connection pools
                          dimitris

                          If you look into the code (org.jboss.management.j2ee.JCAResource) you'll see there is no chance to get anything else than a single array entry:

                           ObjectName jsr77CFName = getConnectionFactory(0);
                           Object[] params = {poolServiceName};
                           String[] sig = {ObjectName.class.getName()};
                           JCAConnectionPoolStatsImpl cfStats = (JCAConnectionPoolStatsImpl)
                           server.invoke(jsr77CFName, "getPoolStats", params, sig);
                           JCAConnectionPoolStatsImpl[] poolStats = {cfStats};
                           stats = new JCAStatsImpl(null, poolStats);
                          


                          I'm not an jsr77 expert, so I suggest you read the spec to be certain what is the expected behaviour. If you spot a mistake in the implementation, post a bug to sourceforge. If something is missing post a feature request, (or better, contribute it yourself :)