【问题标题】:Unable to activate CXF ResponseTimeFeature无法激活 CXF ResponseTimeFeature
【发布时间】:2012-09-03 09:35:07
【问题描述】:

我在 Tomcat 服务器中使用 CXF 公开一个 Web 服务。 我想在 JMX 中公开一些性能信息,例如 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 中的解释非常相似。

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

我在网络应用启动时记录了以下错误:

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]

有人知道如何解决这个问题吗?

提前致谢。

【问题讨论】:

    标签: java spring tomcat cxf jmx


    【解决方案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 WebServices MBean 上可用的属性(例如状态),并且计数器的总线名称不是我设置的。

    【讨论】:

      猜你喜欢
      • 2020-12-20
      • 2017-11-13
      • 1970-01-01
      • 2019-06-28
      • 1970-01-01
      • 2019-03-13
      • 2014-08-30
      • 1970-01-01
      • 2012-10-19
      相关资源
      最近更新 更多