Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Configuring JMX Integration

To

...

enable the

...

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.

JMX integration, register an InstrumentationManager extension with the CXF bus. Using Spring XML, the following minimal XML snippet will enable JMX integration.

noformat
Code Block
xml
xml
<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="
</bean>

The default InstrumentationManager accepts the following configuration options:

Name

Value

Default

enabled

If the JMX integration should be enabled or not

false

bus

The CXF bus instance to register the JMX extension with

None

server

An optional reference to an MBeanServer instance to register MBeans with. If not supplied, an MBeanServer is resolved using the "usePlatformMbeanServer" and/or "serverName" optoins.

None

usePlatformMbeanServer

If true and no reference to an MBeanServer is supplied, the JMX extension registers MBeans with the platform MBean server.

false

serverName

If supplied, usePlatformMbeanServer is false, and no reference to an MBeanServer is supplied, the JMX extension registers MBeans with the MBean server carrying this name.

None

createMBServerConnectorFactory

If true, a connector is created on the MBeanServer.

true

threaded

Determines if the creation of the MBean connector is performed in this thread or in a separate thread. Only relevant if createMBServerConnectorFactory is true.

false

daemon

Determines if the MBean connector creation thread is marked as a daemon thread or not. Only relevant if createMBServerConnectorFactory is true.

false

JMXServiceURL

The URL of the connector to create on the MBeanServer. Only relevant if createMBServerConnectorFactory is true.

service:jmx:rmi:///jndi/rmi://localhost:

...

9913/jmxrmi

...

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.
Image Removed
 
Then you can browse to your endpoint:
 
Image Removed
 
 

...

Example Configuration

Enable JMX integration by adding the following XML to your CXF Spring context.

Code Block
xml
xml

...

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.

No Format

<!-- 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="threadedJMXServiceURL " value="false" />
  <property name="daemon" value="false" />

  <!-- Inject the reference to the MBeanServer -->
  <property name="server" ref="mbeanServerservice:jmx:rmi:///jndi/rmi://localhost:9914/jmxrmi" /> 
</bean>

To test the configuration start up your service and connect to it by using jconsole from the JDK.
Image Added
 
Then you can browse to your endpoint:
 
Image Added
 

Anchor
cxf_in_servicemix
cxf_in_servicemix

Configuring CXF to Use the ServiceMix 4 MBeanServer

If you are embedding a CXF service in a ServiceMix 4 container, the configuration is slightly different from above. You don't want to start a new MBeanServer , instead you and you probably don't want to use the one that the ServiceMix container is already runningcreate additional connectors as the container manages both of these for you. You can do this by injecting get a reference to the running MBeanServercontainer's MBeanServer through the OSGi framework and by inject this reference into the JMX integration extension. Don't forget to add the Spring OSGI namespace and schemaLocation to your CXF configuration file if they are not already present.

noformat
Code Block
xml
xml
<!-- 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" />
  <!-- Unless you really  <property name="threaded" value="false" /want to open an additional connector, set this to false -->
  <property name="daemoncreateMBServerConnectorFactory " value="false" />

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

Anchor
response_time
response_time

How to

...

Get the Request/Response Handling Time?

The 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 upaggregate statistics for services running in the CXF Bus.

Here is the configuration snippet of the that your you should add into the cxf.xmlto your Spring context file to enable response time collection.

noformat
Code Block
xml
xml
    <!-- Wiring the counter repository --> 
    <bean id="CounterRepository" class="org.apache.cxf.management.counters.CounterRepository">
        <property name="bus" ref="cxf" />        
    </bean>

The CounterRepository collects the following metrics: invocations, checked application faults, unchecked application faults, runtime faults, logical runtime faults, total handling time, max handling time, and min handling time.