users@glassfish.java.net

Re: JMS/JMX information in an OSGi bundle

From: Nigel Deakin <nigel.deakin_at_oracle.com>
Date: Wed, 04 Jan 2012 15:55:26 +0000

On 04/01/2012 15:18, Robert Weeks wrote:
> Hi Nigel -
>
>> I can't comment on your osgi problem, but from a MQ perspective your code sample looks fine. Using an
>> AdminConnectionFactory does introduce a dependency on imqjmx.jar but is the easiest way to use the MQ JMX API. I think
>> the convenience classes you use such as
>> DestinationAttributes and DestinationType are also in the same jar.
> Right - and I would like to continue using it - I just didn't want to bundle the libs needed (seems to get it "all" like this - you need imq.jar, imqjmx.jar, imqxm.jar).
>
> I tried putting them in 'lib/applibs' to see if could access via the bundle (making the import dependencies optional so would deploy) - but can't seem to gain access that way either.
>
> Can't really bundle these up as an OSGi lib either, or put in just domains/lib - or will munge with the built in libs needed.

Sivakumar should be able to advise on the best way to make these jars available to a GlassFish application. Is this a normal GlassFish application or something special?

Nigel


>
> Seem my only solution besides constructing a URL (which I would rather use the factory) is to bundle all of these libs with my app and utilize Bundle-Classpath with them.
>
> Thanks for the information.
>
>
>
>> If you can't use imqjmx.jar you can use the JavaSE JMX API but you will need to construct a suitable URL which will
>> require you knowing the port used by GlassFish's RMIRegistry. There are some hints on how to do this on the MQ FAQ:
>> https://wikis.oracle.com/display/GlassFish/OpenMQJMXQuestions
>>
>> Nigel
>>
>> On 04/01/2012 13:29, Robert Weeks wrote:
>>> Hi Sivakumar -
>>>
>>> Thanks for the reply.
>>>
>>> I do know about using the URL approach to avoid using the factory - but was a bit leary on using this in a clustered environment in the future, as well as was hoping I could access it via JNDI or at the very least - have the lib live where bundles can have access to them and not be included in the bundle itself.
>>>
>>> Thanks again!
>>>
>>> ________________________________________
>>> From: Sivakumar Thyagarajan [sivakumar.thyagarajan_at_oracle.com]
>>> Sent: Wednesday, January 04, 2012 6:01 AM
>>> To: users_at_glassfish.java.net
>>> Cc: Robert Weeks
>>> Subject: Re: JMS/JMX information in an OSGi bundle
>>>
>>> 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
>