2012-09-10 30 views
4

我在Tomcat服务器中使用CXF公开Web服务。 我想在JMX中公开一些像ResponseTimeFeature提出的性能信息。无法激活CXF ResponseTimeFeature

我CXF-beans.xml的文件如下:

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

这是非常相似,在CXF JMX page解释。

问题是,当我在[默认地址(服务:jmx:rmi:/// jndi/rmi:// localhost:9913/jmxrmi)]上使用jconsole进行连接时,我看不到任何性能的MBean。我有MyBus的管理信息和里面的服务。但是没有任何关于ResponseTime(即使在SOAP-UI对服务进行负载测试之后)。

我在Web应用程序中记录以下错误启动:

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] 

是否有人对如何解决这个问题的任何想法?

在此先感谢。

回答

1

我终于找到了一个“解决方案”(实际上它只是一种解决方法)。

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

最后在JMX控制台中,我可以看到以下层次结构。

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 

我说的解决办法,因为我失去了一些在正常情况下可在CXF Web服务的MBean属性(如状态实例),并且由于计数器的总线名称是不是我成立。