2012-09-10 97 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屬性(如狀態實例),並且由於計數器的總線名稱是不是我成立。