2.36. 文件集群服务
提供 Camel Cluster Service SPI 的 FileLock 实现
2.36.1. Maven 协调
在 code.quarkus.redhat.com 上使用此扩展创建新项目
或者将协调添加到现有项目中:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-file-cluster-service</artifactId> </dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-file-cluster-service</artifactId>
</dependency>
2.36.2. 其他 Camel Quarkus 配置
2.36.2.1. 在消耗给定端点的集群中只有一个消费者
当将同一路由部署到多个 JVM 上时,可能最好将此扩展与主扩展结合使用。https://docs.redhat.com/en/documentation/red_hat_build_of_apache_camel/4.10/html-single/red_hat_build_of_apache_camel_for_quarkus_reference/#extensions-master在这样的设置中,单个消费者将在整个 camel master 命名空间中一次处于活跃状态。
例如,在多个 JVM 上部署了以下路由:
from("master:ns:timer:test?period=100").log("Timer invoked on a single JVM at a time");
from("master:ns:timer:test?period=100").log("Timer invoked on a single JVM at a time");
可使用如下属性配置文件集群服务:
quarkus.camel.cluster.file.root = target/cluster-folder-where-lock-file-will-be-held
quarkus.camel.cluster.file.root = target/cluster-folder-where-lock-file-will-be-held
因此,单个消费者将在 ns
camel master 命名空间中活跃。这意味着,在一个给定时间,只有一个计时器将在所有 JVM 之间生成交换。换句话说,在某个时间点上,消息将在单个 JVM 上每 100ms 进行一次日志记录。
文件集群服务可以通过 quarkus.camel.cluster.file.*
属性进一步进行调整。
配置属性 | 类型 | default |
---|---|---|
文件锁定群集服务是否应根据 'quarkus.camel.cluster.file.*' 配置自动配置。 |
|
|
集群服务 ID (默认为 null)。 |
| |
根路径(默认为 null)。 |
| |
服务查找顺序/优先级(默认为 2147482647)。 |
| |
[[quarkus-camel-cluster-file-attributes-attributes] 与服务关联的自定义属性(默认为空映射)。 |
| |
开始尝试获取锁定前等待的时间(默认为 1000ms)。 |
| |
尝试获取锁定之间等待的时间(默认为 10000ms)。 |
|
在构建时修复的配置属性。所有其他配置属性可在运行时覆盖。