users@glassfish.java.net

JMS/JMX information in an OSGi bundle

From: Robert Weeks <RWeeks_at_ext-inc.com>
Date: Tue, 3 Jan 2012 13:07:00 -0800

Hello -

I am needing to access information about all of the queues that are running in our app (which are created via OSGi bundles) - and controlled by a central SystemManager bundle.

The main information I need is the queue depth of certain queues.

I know I can do so via the imqcmd scripts, but really want to be able to access this internally in our main bundle and not have to run an outside script to parse the output.

The issue I am having is none of the imq/imqjmx, etc. libraries are exported/available from a bundle to be able to gain access to the correct classes needed to get this - such as the AdminConnectionFactory, JMXConnector, etc.

I was trying to include the libraries (imq.jar, imqjmx.jar) in the bundle and access via the BundleClasspath - but that is really making the bundle larger than needed - and was expecting to be able to access this from the API itself.

Is it correct to have to include the libs in the bundle itself and access via the BundleClasspath?

Example trying to accomplish what I need here:

    AdminConnectionFactory acf = new AdminConnectionFactory();
    try {
        // Using default user/pass. createConnection("user", "pass");
        JMXConnector jmxc = acf.createConnection();
        MBeanServerConnection mbsc = jmxc.getMBeanServerConnection();
        ObjectName destConfigName = MQObjectName.createDestinationConfig(DestinationType.QUEUE, "ExtInt");
        Integer attrValue = (Integer)mbsc.getAttribute(destConfigName, DestinationAttributes.MAX_NUM_PRODUCERS);
        returnString = "Maximum number of producers: " + attrValue;
    } catch (JMException jme) {
        // Do something here.
    } catch (IOException ioe) {
        // Do something here.
    }

Thanks for any information here.



Robert Weeks
Lead Developer - Framework and UI
EXTENSION, INC.
Email: rweeks_at_ext-inc.com
Office: 260-797-0200 x4228
General: 877-207-3753
www.OpenTheRedBox.com