220.11. MicrometerMessageHistoryFactory


此工厂允许使用指标在路由消息期间捕获消息历史性能统计数据。它的工作原理是在所有路由中的每个节点使用 Micrometer Timer。 此工厂可以在 Java 和 XML 中使用,作为以下示例。 

从 Java 中,您要将工厂设置为 CamelContext ,如下所示:

context.setMessageHistoryFactory(new MicrometerMessageHistoryFactory());
Copy to Clipboard Toggle word wrap

在 XML DSL 中,您将定义 <bean>,如下所示:

  <!-- use camel-micrometer message history to gather metrics for all messages being routed -->
  <bean id="metricsMessageHistoryFactory" class="org.apache.camel.component.micrometer.messagehistory.MicrometerMessageHistoryFactory"/>
Copy to Clipboard Toggle word wrap

因工厂支持以下选项:

Expand
名称default描述

prettyPrint

false

是否在以 json 格式输出统计信息时打印情况

meterRegistry

 

允许使用共享的 MeterRegistry。如果没有提供,Camel 将创建此 CamelContext 使用的共享实例。

durationUnit

TimeUnit.MILLISECONDS

将统计作为 json 转储时,使用的单位是持续时间。

在运行时,指标可以从 Java API 或 JMX 访问,后者可以将数据作为 json 输出来收集。

在 Java 代码中,您可以从 CamelContext 获取服务,如下所示:

MicrometerMessageHistoryService service = context.hasService(MicrometerMessageHistoryService.class);
String json = service.dumpStatisticsAsJson();
Copy to Clipboard Toggle word wrap

如果在 CamelContext 中启用了 JMX,则 MBean 会在 type=services 树中注册, 名称为=MicrometerMessageHistory

返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat