2.23. 控制总线


管理和监控 Camel 路由。

2.23.1. 什么是内部

有关用法和配置详情,请参阅上述链接。

2.23.2. Maven 协调

在 code.quarkus.redhat.com 上使用此扩展创建新项目

或者将协调添加到现有项目中:

<dependency>
    <groupId>org.apache.camel.quarkus</groupId>
    <artifactId>camel-quarkus-controlbus</artifactId>
</dependency>
Copy to Clipboard Toggle word wrap

2.23.3. 使用方法

2.23.3.1. Statistics

使用 stats 命令端点时,必须添加 camel-quarkus-management 扩展作为项目依赖项来启用 JMX。Maven 用户必须在其 pom.xml 中添加以下内容:

<dependency>
    <groupId>org.apache.camel.quarkus</groupId>
    <artifactId>camel-quarkus-management</artifactId>
</dependency>
Copy to Clipboard Toggle word wrap

2.23.3.2. 语言

红帽构建的 Apache Camel for Quarkus 中的 Control Bus 扩展中支持以下语言:

2.23.3.2.1. Bean

Bean 语言可用于对 bean 调用方法,以控制路由的状态。org.apache.camel.quarkus:camel-quarkus-bean 扩展必须添加到 classpath 中。Maven 用户必须在 POM 中添加以下依赖项:

<dependency>
    <groupId>org.apache.camel.quarkus</groupId>
    <artifactId>camel-quarkus-bean</artifactId>
</dependency>
Copy to Clipboard Toggle word wrap

在原生模式中,bean 类必须使用 @RegisterForReflection 注解。

2.23.3.2.2. Simple(简单)

Simple 语言可用于控制路由的状态。以下示例使用 ProducerTemplate 停止 ID 为 foo 的路由:

template.sendBody(
    "controlbus:language:simple",
    "${camelContext.getRouteController().stopRoute('foo')}"
);
Copy to Clipboard Toggle word wrap

要使用 OGNL 表示法,org.apache.camel.quarkus:camel-quarkus-bean 扩展必须添加为依赖项。

在原生模式中,必须注册 OGNL 表示法中使用的类以进行反映。在上面的代码片段中,必须注册从 camelContext.getRouteController () 返回的 org.apache.camel.spi.RouteController 类。由于这是第三方类,因此无法使用 @RegisterForReflection 直接标注 - 相反,您可以注解不同的类并指定要注册的目标类。例如,定义 Camel 路由的类可以使用 @RegisterForReflection (targets = { org.apache.camel.spi.RouteController.class }) 注解。

或者,在您的 src/main/resources/application.properties 中添加以下行:

quarkus.camel.native.reflection.include-patterns = org.apache.camel.spi.RouteController
Copy to Clipboard Toggle word wrap

2.23.4. Camel Quarkus 限制

2.23.4.1. Statistics

stats 操作在原生模式中不可用,因为 GraalVM 不支持 JMX。因此,在 classpath 上尝试使用 camel-quarkus-management 扩展构建原生镜像将导致构建失败。

红帽构建的 Apache Camel for Quarkus 不支持此功能。

返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

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

让开源更具包容性

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

關於紅帽

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

Theme

© 2025 Red Hat