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>
Copy to Clipboard

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");
Copy to Clipboard

可使用如下属性配置文件集群服务:

quarkus.camel.cluster.file.root = target/cluster-folder-where-lock-file-will-be-held
Copy to Clipboard

因此,单个消费者将在 ns camel master 命名空间中活跃。这意味着,在一个给定时间,只有一个计时器将在所有 JVM 之间生成交换。换句话说,在某个时间点上,消息将在单个 JVM 上每 100ms 进行一次日志记录。

文件集群服务可以通过 quarkus.camel.cluster.file.* 属性进一步进行调整。

配置属性类型default

quarkus.camel.cluster.file.enabled

文件锁定群集服务是否应根据 'quarkus.camel.cluster.file.*' 配置自动配置。

布尔值

true

quarkus.camel.cluster.file.id

集群服务 ID (默认为 null)。

string

 

quarkus.camel.cluster.file.root

根路径(默认为 null)。

string

 

quarkus.camel.cluster.file.order

服务查找顺序/优先级(默认为 2147482647)。

int

 

[[quarkus-camel-cluster-file-attributes-​attributes] quarkus.camel.cluster.file.attributes."attributes"

与服务关联的自定义属性(默认为空映射)。

Map<String,String>

 

quarkus.camel.cluster.file.acquire-lock-delay

开始尝试获取锁定前等待的时间(默认为 1000ms)。

string

 

quarkus.camel.cluster.file.acquire-lock-interval

尝试获取锁定之间等待的时间(默认为 10000ms)。

string

 

在构建时修复的配置属性。所有其他配置属性可在运行时覆盖。

返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

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

让开源更具包容性

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

關於紅帽

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

Theme

© 2025 Red Hat