2.17. 控制总线


管理和监控 Camel 路由。

2.17.1. 内部

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

2.17.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.17.3. 使用

2.17.3.1. 语言

在 Camel Extensions for Quarkus 中的 Control Bus 扩展中支持以下语言:

2.17.3.1.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.17.3.1.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.17.4. Camel Quarkus 限制

2.17.4.1. Statistics

Camel Extensions for Quarkus 不支持此功能。

返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

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

让开源更具包容性

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

關於紅帽

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

Theme

© 2025 Red Hat