2.23. 控制总线
管理和监控 Camel 路由。
2.23.1. 什么是内部 复制链接链接已复制到粘贴板!
-
Control Bus 组件, URI 语法:
controlbus:command:language
有关用法和配置详情,请参阅上述链接。
2.23.2. Maven 协调 复制链接链接已复制到粘贴板!
在 code.quarkus.redhat.com 上使用此扩展创建新项目
或者将协调添加到现有项目中:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-controlbus</artifactId> </dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-controlbus</artifactId>
</dependency>
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>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-management</artifactId>
</dependency>
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>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-bean</artifactId>
</dependency>
在原生模式中,bean 类必须使用 @RegisterForReflection
注解。
2.23.3.2.2. Simple(简单) 复制链接链接已复制到粘贴板!
Simple 语言可用于控制路由的状态。以下示例使用 ProducerTemplate
停止 ID 为 foo
的路由:
template.sendBody( "controlbus:language:simple", "${camelContext.getRouteController().stopRoute('foo')}" );
template.sendBody(
"controlbus:language:simple",
"${camelContext.getRouteController().stopRoute('foo')}"
);
要使用 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
quarkus.camel.native.reflection.include-patterns = org.apache.camel.spi.RouteController
2.23.4. Camel Quarkus 限制 复制链接链接已复制到粘贴板!
2.23.4.1. Statistics 复制链接链接已复制到粘贴板!
stats
操作在原生模式中不可用,因为 GraalVM 不支持 JMX。因此,在 classpath 上尝试使用 camel-quarkus-management
扩展构建原生镜像将导致构建失败。
红帽构建的 Apache Camel for Quarkus 不支持此功能。