【问题标题】:How to enable JMX monitoring for akka-camel endpoints如何为 akka-camel 端点启用 JMX 监控
【发布时间】: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


    【解决方案1】:

    Akka 文档非常广泛。

    akka {
      camel {
      # Whether JMX should be enabled or disabled for the Camel Context
      jmx = off
      …
      }
    }
    

    【讨论】:

      【解决方案2】:

      我将从查看最新的 Akka Camel Docs here 开始。如果您向下滚动一点,您将看到一个名为CamelExtension 的标题。在此标题下,您将看到有关如何获取系统使用的CamelContext 的信息。拥有CamelContext 后,您会注意到上面有一个名为setManagementStrategy 的方法。您应该能够使用它来设置ManagedManagementStrategy 的实例(文档here),并希望这将启用您需要的JMX 优点。我说希望是因为我不确定,因为我自己没有尝试过。

      【讨论】:

      • 您的评论也帮助了我。将在问题中进行编辑以反映最终解决方案。谢谢!
      猜你喜欢
      • 2021-02-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-11
      • 2023-03-14
      • 2015-06-08
      • 2015-01-03
      相关资源
      最近更新 更多