Monitoring and Administration using JMX - 7.0

Talend ESB Container Administration Guide

EnrichVersion
7.0
EnrichProdName
Talend Data Fabric
Talend Data Services Platform
Talend ESB
Talend MDM Platform
Talend Open Studio for ESB
Talend Real-Time Big Data Platform
task
Administration and Monitoring
Design and Development
Installation and Upgrade
EnrichPlatform
Talend ESB

Apache Karaf provides a large set of MBeans that allow you to fully monitor and administrate Karaf using any JMX client (for example, JConsole provided in the Oracle or IBM JDK). They provide more or less the same actions that you can do using the Karaf shell commands. The list of MBeans available:

Table 9. Karaf Management MBeans

MBean (org.apache.karaf:type value)

Description

admin administrates the child instances
bundles manipulates the OSGi bundles
config manipulates the Karaf configuration files (in the /etc folder) and the ConfigAdmin layer
dev provides information and administration of the OSGi framework
diagnostic used to create information files (dumps) about Karaf activity
features manipulate the Karaf features
log manipulate the logging layer
packages manipulate the PackageAdmin layer and get information about exported and imported packages
services to get information about the OSGi services
system to shutdown the Karaf container itself
web to get information about the Web bundles (installed with the war feature)
obr to manipulate the OBR layer (installed with the obr feature)

For MBean registration, the Karaf container exposes a MBeanServer as an OSGI service. This server is created when Karaf boots and can be used to register your own MBeans. The process is really simple as it only requires that the bean/pojo of the project extend the javax.management.StandardMBean class and implement an interface where the name of the class must contain the extension MBean. Below shows an example based on Karaf WebMBean:

  1. Create the interface definition.

    /**
     * Describe the web MBean.
     */
    public interface WebMBean {
    ...
    }
  2. Create the implementation. The class must extend the javax.management.StandardMBean class and implement the interface.

    /**
     * Implementation of the web MBean.
     */
    public class Web extends StandardMBean implements WebMBean {
    
        private WebContainerService webContainerService;
    
        public Web() throws NotCompliantMBeanException {
            super(WebMBean.class);
        }
    ...
  3. Create the Blueprint file. The blueprint file will contain definition of the beans to be instantiated and OSGI services to look up or register. Basically, 2 things should be done : lookup to retrieve the MBeanServer and next registers its Mbean using the MBeanRegister of Karaf.

    <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
    
        <!-- Reference to the MBean Server -->
        <reference id="mbeanServer" interface="javax.management.MBeanServer">
            <reference-listener ref="mbeanRegistrer"
                bind-method="registerMBeanServer" 
                unbind-method="unregisterMBeanServer"/>
        </reference>
    
        <!-- Web MBean -->
        <bean id="webMBean" 
            class="org.apache.karaf.management.mbeans.web.internal.WebMBeanImpl">
            <property name="bundleContext" ref="blueprintBundleContext"/>
        </bean>
    
        <!-- MBean Registrer -->
        <bean id="mbeanRegistrer" 
            class="org.apache.karaf.management.MBeanRegistrer" init-method="init" 
            destroy-method="destroy">
            <property name="mbeans">
                <map>
                    <entry value="org.apache.karaf:type=web,name=${karaf.name}" 
                    key-ref="webMBean"/>
                </map>
            </property>
        </bean>
    
    </blueprint>