【发布时间】:2013-07-13 12:35:58
【问题描述】:
我有一个 Akka 应用程序(akka 2.2.0、akka-camel、camel 2.10.5)。 该应用程序包括生产者组件,即:
class MyProducer extends Actor with Producer with akka.actor.ActorLogging {
...
我想让 Camel 通过 JMX 自动公开这些生产者的监控属性,以查看已交换的消息数量、平均时间、吞吐量等。
理论上Apache Camel has extensive support for JMX to allow you to monitor and control the Camel managed objects with a JMX client。在实践中,我启用了 JMX 代理
<jmxAgent
id="agent"
disabled="false"
createConnector="true"
usePlatformMBeanServer="true"
mbeanServerDefaultDomain="localhost"
registryPort="1346"
registerAlways="true"
registerNewRoutes="true"
/>
这会导致一系列 Camel 信息显示为 mbean(例如,从 VisualVM 中看到)但在“端点”下没有关于我的 Producer 演员的信息。
我试过用
装饰演员@ManagedResource
这似乎没有任何效果。 文档说
"从 Camel 2.1 开始,只有单例端点被注册为 在以下情况下,非单身人士的开销将是巨大的 使用了数千或数百万个端点。这可能发生在 使用收件人列表 EIP 或来自发送大量的 ProducerTemplate 的消息。 "
我想知道我的 Producer 演员是否因此不公开信息(我不清楚究竟是什么类型的端点是由 Producer trait 产生的)。
我究竟需要做什么才能为我的 akka-camel 端点启用 JMX 监控(由于使用 Producer trait)?
编辑: Viktor 指出我需要重新定义配置属性。 这是必要的,但还不够。还需要强制 Camel 管理您的端点。我不得不添加这个:
camelContext.addRegisterEndpointCallback(new EndpointStrategy {
def registerEndpoint(name: String, ep: Endpoint) = {
camelContext.getManagementStrategy.manageObject(ep)
ep
}
})
【问题讨论】:
标签: scala apache-camel akka