users@glassfish.java.net

Re: JMS/JMX information in an OSGi bundle

From: Sivakumar Thyagarajan <sivakumar.thyagarajan_at_oracle.com>
Date: Wed, 04 Jan 2012 16:31:14 +0530

Hi Robert

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

I think the imqjmx.jar needs to be in the classpath [1] only to obtain
the JMX Connector through the convenience AdminConnectorFactory. There
is another method to obtain a JMX connector using standard JMX classes
instead, described in [2]. Would that help?

Thanks
--Siva.
[1] http://docs.oracle.com/cd/E18930_01/html/821-2441/gdrrv.html#scrolltoc
[2] http://docs.oracle.com/cd/E18930_01/html/821-2441/gchjb.html#scrolltoc
On Wednesday 04 January 2012 02:37 AM, Robert Weeks wrote:
> 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
>