Search code examples
javajmxfuseesbblueprint-osgijbossfuse

Simplest way to register an MBean (JMX) in JBoss Fuse Fabric?


I've written a custom MBean for my service running in JBoss Fuse Fabric (v7.2.0.redhat-024)

  • Interface: com.mycompany.myservice.MyServiceManagerMBean
  • Implementation class: com.mycompany.myservice.MyServiceManager

What is the simplest way for my MBean to be registered or "discovered" by JBoss Fuse?

I tried adding the following to my blueprint.xml, but it doesnt seem to work:

<bean id="org.apache.cxf.management.InstrumentationManager" class="org.apache.cxf.management.jmx.InstrumentationManagerImpl">
    <property name="enabled" value="true" />
    <property name="bus" ref="cxf" />
    <property name="usePlatformMBeanServer" value="true" />
</bean>

I run JBoss Fuse Fabric with the profile that deploys my services, I fire up JConsole and I connect to the first Local Process named org.apache.karaf.man.Main (there are 2 of them).

Yet I cant find my MBean - I'm expecting to see com.mycompany.myservice on the MBean tab, but it isn't there.

In contrast, I can see all of my datasource jmx beans under this tree node:

com.mycompany.anotherservice.datasources.

However the datasource MBeans were configured by setting jmxEnabled=true, so I am none the wiser about how to configure and expose my own MBean.

Could someone please tell me what I need to do here?

Thanks in advance.


Solution

  • And here is a way to do this in the JBoss Fuse blueprint.xml configuration

    <bean id="mbeanRegistrer" class="org.apache.karaf.management.MBeanRegistrer" init-method="init">
        <property name="bundleContext" ref="blueprintBundleContext"/>
        <property name="mbeans">
            <map>
                <entry value="com.mycompany.myservice:type=admin,name=myadminBean" key-ref="myadminBean"/>
            </map>
        </property>
    </bean>
    

    Thanks to my colleague Y.H. for help :)