我正在使用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]
有人对如何解决这个问题有任何想法吗?
提前致谢。
最佳答案
我终于找到了一个“解决方案”(实际上这只是一种解决方法)。
<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上可用的属性(例如状态),并且因为计数器的总线名称不是我设置的。