You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 8 Next »

How to enable the CXF instrumentationManager

CXF Endpoints can be managed with JMX. You simply have add the following configuration to your cxf.xml which will enable the CXF management module to work.

<bean id="org.apache.cxf.management.InstrumentationManager"
  class="org.apache.cxf.management.jmx.InstrumentationManagerImpl">
  <property name="bus" ref="cxf" />
  <property name="enabled" value="true" />
  <property name="threaded" value="false" />
  <property name="daemon" value="false" />
  <property name="JMXServiceURL" value="service:jmx:rmi:///jndi/rmi://localhost:9914/jmxrmi" />
</bean>

To avoid any unnecessary runtime overhead, the performance counters measuring response time are disabled by default. Further configuration is required to enable this instrumentation.

To test the configuration start up your service and connect to it by using jconsole from the jdk.

 
Then you can browse to your endpoint:
 

 
 

Configuring CXF to Use the ServiceMix MBeanServer

If you are embedding a CXF service in a ServiceMix container, the configuration is different. You don't want to start a new MBeanServer, instead you want to use the one that the ServiceMix container is already running. You can do this by injecting a reference to the running MBeanServer. Don't forget to add the namespace and schemaLocation to your CXF configuration file if they are not already present.

<!-- OSGi namespace and schemaLocation required -->
<beans ...
       xmlns:osgi="http://www.springframework.org/schema/osgi"
       ...      
       xsi:schemaLocation="...
       http://www.springframework.org/schema/osgi  http://www.springframework.org/schema/osgi/spring-osgi.xsd">

...

<!-- Grab a reference to the current MBeanServer -->
<osgi:reference id="mbeanServer" interface="javax.management.MBeanServer" cardinality="0..1"/>

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

  <!-- Inject the reference to the MBeanServer -->
  <property name="server" ref="mbeanServer" /> 
</bean>

How to get the request response handling time ?

CXF management module also provides a feature which can get the ongoing message's response time (the Time that CXF get the response - the Time that CXF get the request), since we can't store each of the message handling time, we just store the longest response time in the counter repository which you can use jconsole to look up.

Here is the configuration snippet of the that your should add into the cxf.xml

    <!-- Wiring the counter repository --> 
    <bean id="CounterRepository" class="org.apache.cxf.management.counters.CounterRepository">
        <property name="bus" ref="cxf" />        
    </bean>
  • No labels