4
votes

I'm exposing a Web service using CXF inside a Tomcat server. I would like to expose in JMX some performance information like those proposed by the ResponseTimeFeature.

My cxf-beans.xml file is as follows:

<cxf:bus bus="cxf" id="MyBus">
  <cxf:properties>
    <entry key="bus.jmx.enabled" value="true" />
  </cxf:properties>
</cxf:bus>

<bean id="CounterRepository" class="org.apache.cxf.management.counters.CounterRepository">
  <property name="bus" ref="cxf" />
</bean>

<jaxws:endpoint id="analyserEndpoint" implementor="#analyserImpl" address="/analyser">
  <jaxws:features>
    <bean class="org.apache.cxf.management.interceptor.ResponseTimeFeature" />
  </jaxws:features>
</jaxws:endpoint>

Which is very similar to what is explained in CXF JMX page.

The problem is that when I connect using the jconsole at the [default address (service:jmx:rmi:///jndi/rmi://localhost:9913/jmxrmi)], I can't see any performance MBean. I have management information of MyBus and the service inside. But nothing about ResponseTime (Even after a SOAP-UI load test over the service).

I have the following error logged at web app start up:

2012-09-10 15:13:19,692 ERROR org.apache.cxf.management.jmx.InstrumentationManagerImpl - Could not start JMX connector server : java.io.IOException: Cannot bind to URL [rmi://localhost:9913/jmxrmi]: javax.naming.NameAlreadyBoundException: jmxrmi [Root exception is java.rmi.AlreadyBoundException: jmxrmi]

Does someone has any idea on how to solve this problem?

Thanks in advance.

1

1 Answers

1
votes

I finally found a "solution" (in fact it is just a workaround).

<cxf:bus bus="MyBus" id="MyBus" name="MyBus">
  <cxf:properties>
    <entry key="bus.jmx.enabled" value="true" />
    <entry key="bus.jmx.persistentBusId" value="MyBus" />
    <entry key="bus.jmx.usePlatformMBeanServer" value="true" />
    <entry key="bus.jmx.createMBServerConnectorFactory" value="false" />
  </cxf:properties>
</cxf:bus>

<bean id="CounterRepository" class="org.apache.cxf.management.counters.CounterRepository">
  <property name="bus" ref="MyBus" />
</bean>

<jaxws:endpoint id="analyserEndpoint" implementor="#analyserImpl" address="/analyser">
  <jaxws:features>
    <bean class="org.apache.cxf.management.interceptor.ResponseTimeFeature" />
  </jaxws:features>
</jaxws:endpoint>

At the end in the JMX Console I can see the following hierarchy.

org.apache.cxf
  Bus
    MyBus
      Operations
        shutdown
      Notifications
  Performance.Counter.Server
    cxf+random_number
      "WebServiceServiceNameAsAQName"
        "WebServicePortName"
          Attributes
            NumInvocations
            AvgResponseTime
            MaxResponseTime
            MinResponseTime
            NumCheckedApplicationFaults
            NumLogicalRuntimeFaults
            NumRuntimeFaults
            NumUnCheckedApplicationFaults
            TotalHandlingTime
          Operations
            reset
          "WebServiceMethodName"
            Attributes (same as above, per method)
            Operations
              reset

I say workaround, since I lost some of the attributes that are normally available on CXF WebServices MBeans (like state for instance) and since the bus name of the counter is not the one I set up.