質問

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.

役に立ちましたか?

解決

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 :)

他のヒント

I received the following code snippet which should solve this problem.

First, you inject the cxf bus into a bean in blueprint.xml via <property name="bus" ref="cxf"/> and use it to register the bean with the InstrumentationManager:

    MyMBean mbean = new MyMBeanImpl();
    InstrumentationManager imanager = bus.getExtension(InstrumentationManager.class);
    final ObjectName objectName = new ObjectName("org.apache.cxf:type=foo,name=bar");
    imanager.register(mbean, objectName);

I am still having problems with this, bus.getExtension(InstrumentationManager.class) returns null, but I am told this is the proper solution...

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top