This is an automated email from the ASF dual-hosted git repository.

jamesnetherton pushed a commit to branch 2.13.x
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git

commit ae9ac0edd711df8b7cda100fc40e4bf4e1bfc7a2
Author: aldettinger <aldettin...@gmail.com>
AuthorDate: Tue Nov 8 15:37:45 2022 +0100

    automatic configuration of FileLockClusterService #4262
---
 .../ROOT/pages/reference/extensions/file.adoc      |  81 +++++++++++++++++
 .../ROOT/pages/reference/extensions/master.adoc    |   1 +
 extensions/file/deployment/pom.xml                 |   5 +
 .../FileLockClusterServiceProcessor.java           |  41 +++++++++
 ...LockClusterServiceConfigDefaultEnabledTest.java |  92 +++++++++++++++++++
 .../FileLockClusterServiceConfigDefaultTest.java   |  74 +++++++++++++++
 ...kClusterServiceConfigNonDefaultEnabledTest.java | 101 +++++++++++++++++++++
 .../file/runtime/src/main/doc/configuration.adoc   |  23 +++++
 .../file/cluster/FileLockClusterServiceConfig.java |  80 ++++++++++++++++
 .../cluster/FileLockClusterServiceRecorder.java    |  49 ++++++++++
 .../master/runtime/src/main/doc/configuration.adoc |   1 +
 11 files changed, 548 insertions(+)

diff --git a/docs/modules/ROOT/pages/reference/extensions/file.adoc 
b/docs/modules/ROOT/pages/reference/extensions/file.adoc
index 5c4676e61d..90f69ee3e3 100644
--- a/docs/modules/ROOT/pages/reference/extensions/file.adoc
+++ b/docs/modules/ROOT/pages/reference/extensions/file.adoc
@@ -44,3 +44,84 @@ Or add the coordinates to your existing project:
 ifeval::[{doc-show-user-guide-link} == true]
 Check the xref:user-guide/index.adoc[User guide] for more information about 
writing Camel Quarkus applications.
 endif::[]
+
+[id="extensions-file-additional-camel-quarkus-configuration"]
+== Additional Camel Quarkus configuration
+
+
+[id="extensions-file-configuration-having-only-a-single-consumer-in-a-cluster-consuming-from-a-given-endpoint"]
+=== Having only a single consumer in a cluster consuming from a given endpoint
+
+When the same route is deployed on multiple JVMs, it could be interesting to 
use this extension in conjunction with the 
xref:reference/extensions/master.adoc[Master one].
+In such a setup, a single consumer will be active at a time across the whole 
camel master namespace.
+
+For instance, having the route below deployed on multiple JVMs:
+
+```
+from("master:ns:timer:test?period=100").log("Timer invoked on a single JVM at 
a time");
+```
+
+It's possible to enable the file cluster service with a property like below:
+
+```
+quarkus.camel.cluster.file.enabled = true
+```
+
+As a result, a single consumer will be active across the `ns` camel master 
namespace.
+It means that, at a given time, only a single timer will generate exchanges 
across all JVMs.
+In other words, messages will be logged every 100ms on a single JVM at a time.
+
+The file cluster service could further be tuned by tweaking 
`quarkus.camel.cluster.file.*` properties.
+
+
+[width="100%",cols="80,5,15",options="header"]
+|===
+| Configuration property | Type | Default
+
+
+|icon:lock[title=Fixed at build time] 
[[quarkus.camel.cluster.file.enabled]]`link:#quarkus.camel.cluster.file.enabled[quarkus.camel.cluster.file.enabled]`
+
+Whether a File Lock Cluster Service should be automatically configured 
according to 'quarkus.camel.cluster.file.++*++' configurations.
+| `boolean`
+| `false`
+
+|icon:lock[title=Fixed at build time] 
[[quarkus.camel.cluster.file.id]]`link:#quarkus.camel.cluster.file.id[quarkus.camel.cluster.file.id]`
+
+The cluster service ID (defaults to null).
+| `string`
+| 
+
+|icon:lock[title=Fixed at build time] 
[[quarkus.camel.cluster.file.root]]`link:#quarkus.camel.cluster.file.root[quarkus.camel.cluster.file.root]`
+
+The root path (defaults to null).
+| `string`
+| 
+
+|icon:lock[title=Fixed at build time] 
[[quarkus.camel.cluster.file.order]]`link:#quarkus.camel.cluster.file.order[quarkus.camel.cluster.file.order]`
+
+The service lookup order/priority (defaults to 2147482647).
+| `java.lang.Integer`
+| 
+
+|icon:lock[title=Fixed at build time] 
[[quarkus.camel.cluster.file.acquire-lock-delay]]`link:#quarkus.camel.cluster.file.acquire-lock-delay[quarkus.camel.cluster.file.acquire-lock-delay]`
+
+The time to wait before starting to try to acquire lock (defaults to 1000ms).
+| `string`
+| 
+
+|icon:lock[title=Fixed at build time] 
[[quarkus.camel.cluster.file.acquire-lock-interval]]`link:#quarkus.camel.cluster.file.acquire-lock-interval[quarkus.camel.cluster.file.acquire-lock-interval]`
+
+The time to wait between attempts to try to acquire lock (defaults to 10000ms).
+| `string`
+| 
+
+|icon:lock[title=Fixed at build time] 
[[quarkus.camel.cluster.file.attributes]]`link:#quarkus.camel.cluster.file.attributes[quarkus.camel.cluster.file.attributes]`
+
+The custom attributes associated to the service (defaults to empty map).
+| ``Map<String,String>``
+| 
+|===
+
+[.configuration-legend]
+{doc-link-icon-lock}[title=Fixed at build time] Configuration property fixed 
at build time. All other configuration properties are overridable at runtime.
+
diff --git a/docs/modules/ROOT/pages/reference/extensions/master.adoc 
b/docs/modules/ROOT/pages/reference/extensions/master.adoc
index 09c2ce58bc..d5e7bf3c11 100644
--- a/docs/modules/ROOT/pages/reference/extensions/master.adoc
+++ b/docs/modules/ROOT/pages/reference/extensions/master.adoc
@@ -50,5 +50,6 @@ endif::[]
 
 This extension can be used in conjunction with extensions below:
 
+* xref:reference/extensions/file.adoc[Camel Quarkus File]
 * xref:reference/extensions/kubernetes.adoc[Camel Quarkus Kubernetes]
 
diff --git a/extensions/file/deployment/pom.xml 
b/extensions/file/deployment/pom.xml
index f0041bdfab..f0ef69e136 100644
--- a/extensions/file/deployment/pom.xml
+++ b/extensions/file/deployment/pom.xml
@@ -38,6 +38,11 @@
             <groupId>org.apache.camel.quarkus</groupId>
             <artifactId>camel-quarkus-file</artifactId>
         </dependency>
+        <dependency>
+            <groupId>io.quarkus</groupId>
+            <artifactId>quarkus-junit5-internal</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
     <build>
diff --git 
a/extensions/file/deployment/src/main/java/org/apache/camel/quarkus/component/file/cluster/deployment/FileLockClusterServiceProcessor.java
 
b/extensions/file/deployment/src/main/java/org/apache/camel/quarkus/component/file/cluster/deployment/FileLockClusterServiceProcessor.java
new file mode 100644
index 0000000000..36793289ed
--- /dev/null
+++ 
b/extensions/file/deployment/src/main/java/org/apache/camel/quarkus/component/file/cluster/deployment/FileLockClusterServiceProcessor.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.file.cluster.deployment;
+
+import io.quarkus.deployment.annotations.BuildStep;
+import io.quarkus.deployment.annotations.Consume;
+import io.quarkus.deployment.annotations.ExecutionTime;
+import io.quarkus.deployment.annotations.Record;
+import io.quarkus.runtime.RuntimeValue;
+import org.apache.camel.component.file.cluster.FileLockClusterService;
+import 
org.apache.camel.quarkus.component.file.cluster.FileLockClusterServiceConfig;
+import 
org.apache.camel.quarkus.component.file.cluster.FileLockClusterServiceRecorder;
+import org.apache.camel.quarkus.core.deployment.spi.CamelBeanBuildItem;
+import org.apache.camel.quarkus.core.deployment.spi.CamelContextBuildItem;
+
+class FileLockClusterServiceProcessor {
+
+    @Record(ExecutionTime.STATIC_INIT)
+    @BuildStep(onlyIf = FileLockClusterServiceConfig.Enabled.class)
+    @Consume(CamelContextBuildItem.class)
+    CamelBeanBuildItem 
setupFileLockClusterService(FileLockClusterServiceConfig config,
+            FileLockClusterServiceRecorder recorder) {
+
+        final RuntimeValue<FileLockClusterService> flcs = 
recorder.createFileLockClusterService(config);
+        return new CamelBeanBuildItem("fileLockClusterService", 
FileLockClusterService.class.getName(), flcs);
+    }
+}
diff --git 
a/extensions/file/deployment/src/test/java/org/apache/camel/quarkus/component/file/cluster/deployment/FileLockClusterServiceConfigDefaultEnabledTest.java
 
b/extensions/file/deployment/src/test/java/org/apache/camel/quarkus/component/file/cluster/deployment/FileLockClusterServiceConfigDefaultEnabledTest.java
new file mode 100644
index 0000000000..1a6e13cb74
--- /dev/null
+++ 
b/extensions/file/deployment/src/test/java/org/apache/camel/quarkus/component/file/cluster/deployment/FileLockClusterServiceConfigDefaultEnabledTest.java
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.file.cluster.deployment;
+
+import java.io.IOException;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.util.Properties;
+import java.util.concurrent.TimeUnit;
+
+import javax.inject.Inject;
+
+import io.quarkus.test.QuarkusUnitTest;
+import org.apache.camel.CamelContext;
+import org.apache.camel.Ordered;
+import org.apache.camel.component.file.cluster.FileLockClusterService;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.Asset;
+import org.jboss.shrinkwrap.api.asset.StringAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class FileLockClusterServiceConfigDefaultEnabledTest {
+
+    @RegisterExtension
+    static final QuarkusUnitTest CONFIG = new QuarkusUnitTest()
+            .setArchiveProducer(() -> 
ShrinkWrap.create(JavaArchive.class).addAsResource(applicationProperties(),
+                    "application.properties"));
+
+    public static final Asset applicationProperties() {
+        Writer writer = new StringWriter();
+
+        Properties props = new Properties();
+        props.setProperty("quarkus.camel.cluster.file.enabled", "true");
+
+        try {
+            props.store(writer, "");
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+
+        return new StringAsset(writer.toString());
+    }
+
+    @Inject
+    CamelContext camelContext;
+
+    @Test
+    public void defaultEnabledConfigShouldAutoConfigureWithDefaults() {
+
+        DefaultCamelContext dcc = 
camelContext.adapt(DefaultCamelContext.class);
+        assertNotNull(dcc);
+
+        FileLockClusterService[] flcs = dcc.getServices().stream().filter(s -> 
s instanceof FileLockClusterService)
+                .toArray(FileLockClusterService[]::new);
+        assertEquals(1, flcs.length);
+
+        FileLockClusterService service = flcs[0];
+        assertNotNull(service);
+
+        assertNull(service.getId());
+        assertNull(service.getRoot());
+        assertEquals(Ordered.LOWEST, service.getOrder());
+        assertNotNull(service.getAttributes());
+        assertTrue(service.getAttributes().isEmpty());
+        assertEquals(1L, service.getAcquireLockDelay());
+        assertEquals(TimeUnit.SECONDS, service.getAcquireLockDelayUnit());
+        assertEquals(10L, service.getAcquireLockInterval());
+        assertEquals(TimeUnit.SECONDS, service.getAcquireLockIntervalUnit());
+    }
+}
diff --git 
a/extensions/file/deployment/src/test/java/org/apache/camel/quarkus/component/file/cluster/deployment/FileLockClusterServiceConfigDefaultTest.java
 
b/extensions/file/deployment/src/test/java/org/apache/camel/quarkus/component/file/cluster/deployment/FileLockClusterServiceConfigDefaultTest.java
new file mode 100644
index 0000000000..52ad45157a
--- /dev/null
+++ 
b/extensions/file/deployment/src/test/java/org/apache/camel/quarkus/component/file/cluster/deployment/FileLockClusterServiceConfigDefaultTest.java
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.file.cluster.deployment;
+
+import java.io.IOException;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.util.Properties;
+
+import javax.inject.Inject;
+
+import io.quarkus.test.QuarkusUnitTest;
+import org.apache.camel.CamelContext;
+import org.apache.camel.component.file.cluster.FileLockClusterService;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.Asset;
+import org.jboss.shrinkwrap.api.asset.StringAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+public class FileLockClusterServiceConfigDefaultTest {
+
+    @RegisterExtension
+    static final QuarkusUnitTest CONFIG = new QuarkusUnitTest()
+            .setArchiveProducer(() -> 
ShrinkWrap.create(JavaArchive.class).addAsResource(applicationProperties(),
+                    "application.properties"));
+
+    public static final Asset applicationProperties() {
+        Writer writer = new StringWriter();
+
+        Properties props = new Properties();
+
+        try {
+            props.store(writer, "");
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+
+        return new StringAsset(writer.toString());
+    }
+
+    @Inject
+    CamelContext camelContext;
+
+    @Test
+    public void defaultConfigShouldNotAutoConfigure() {
+
+        DefaultCamelContext dcc = 
camelContext.adapt(DefaultCamelContext.class);
+        assertNotNull(dcc);
+
+        FileLockClusterService[] flcs = dcc.getServices().stream().filter(s -> 
s instanceof FileLockClusterService)
+                .toArray(FileLockClusterService[]::new);
+        assertEquals(0, flcs.length);
+    }
+}
diff --git 
a/extensions/file/deployment/src/test/java/org/apache/camel/quarkus/component/file/cluster/deployment/FileLockClusterServiceConfigNonDefaultEnabledTest.java
 
b/extensions/file/deployment/src/test/java/org/apache/camel/quarkus/component/file/cluster/deployment/FileLockClusterServiceConfigNonDefaultEnabledTest.java
new file mode 100644
index 0000000000..114443f1c2
--- /dev/null
+++ 
b/extensions/file/deployment/src/test/java/org/apache/camel/quarkus/component/file/cluster/deployment/FileLockClusterServiceConfigNonDefaultEnabledTest.java
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.file.cluster.deployment;
+
+import java.io.IOException;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.util.Properties;
+import java.util.concurrent.TimeUnit;
+
+import javax.inject.Inject;
+
+import io.quarkus.test.QuarkusUnitTest;
+import org.apache.camel.CamelContext;
+import org.apache.camel.component.file.cluster.FileLockClusterService;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.Asset;
+import org.jboss.shrinkwrap.api.asset.StringAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class FileLockClusterServiceConfigNonDefaultEnabledTest {
+
+    @RegisterExtension
+    static final QuarkusUnitTest CONFIG = new QuarkusUnitTest()
+            .setArchiveProducer(() -> 
ShrinkWrap.create(JavaArchive.class).addAsResource(applicationProperties(),
+                    "application.properties"));
+
+    public static final Asset applicationProperties() {
+        Writer writer = new StringWriter();
+
+        Properties props = new Properties();
+        props.setProperty("quarkus.camel.cluster.file.enabled", "true");
+        props.setProperty("quarkus.camel.cluster.file.id", "service-id");
+        props.setProperty("quarkus.camel.cluster.file.root", "root-path");
+        props.setProperty("quarkus.camel.cluster.file.order", "10");
+        props.setProperty("quarkus.camel.cluster.file.attributes.key1", 
"value1");
+        props.setProperty("quarkus.camel.cluster.file.attributes.key2", 
"value2");
+        props.setProperty("quarkus.camel.cluster.file.acquire-lock-delay", 
"5");
+        props.setProperty("quarkus.camel.cluster.file.acquire-lock-interval", 
"1h");
+
+        try {
+            props.store(writer, "");
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+
+        return new StringAsset(writer.toString());
+    }
+
+    @Inject
+    CamelContext camelContext;
+
+    @Test
+    public void nonDefaultEnabledConfigShouldAutoConfigureWithoutDefaults() {
+
+        DefaultCamelContext dcc = 
camelContext.adapt(DefaultCamelContext.class);
+        assertNotNull(dcc);
+
+        FileLockClusterService[] flcs = dcc.getServices().stream().filter(s -> 
s instanceof FileLockClusterService)
+                .toArray(FileLockClusterService[]::new);
+        assertEquals(1, flcs.length);
+
+        FileLockClusterService service = flcs[0];
+        assertNotNull(service);
+        assertEquals("service-id", service.getId());
+        assertEquals("root-path", service.getRoot());
+        assertEquals(10, service.getOrder());
+
+        assertNotNull(service.getAttributes());
+        assertTrue(service.getAttributes().containsKey("key1"));
+        assertEquals("value1", service.getAttributes().get("key1"));
+        assertTrue(service.getAttributes().containsKey("key2"));
+        assertEquals("value2", service.getAttributes().get("key2"));
+
+        assertEquals(5L, service.getAcquireLockDelay());
+        assertEquals(TimeUnit.MILLISECONDS, service.getAcquireLockDelayUnit());
+        assertEquals(3600000, service.getAcquireLockInterval());
+        assertEquals(TimeUnit.MILLISECONDS, 
service.getAcquireLockIntervalUnit());
+    }
+}
diff --git a/extensions/file/runtime/src/main/doc/configuration.adoc 
b/extensions/file/runtime/src/main/doc/configuration.adoc
new file mode 100644
index 0000000000..194f451d48
--- /dev/null
+++ b/extensions/file/runtime/src/main/doc/configuration.adoc
@@ -0,0 +1,23 @@
+
+=== Having only a single consumer in a cluster consuming from a given endpoint
+
+When the same route is deployed on multiple JVMs, it could be interesting to 
use this extension in conjunction with the 
xref:reference/extensions/master.adoc[Master one].
+In such a setup, a single consumer will be active at a time across the whole 
camel master namespace.
+
+For instance, having the route below deployed on multiple JVMs:
+
+```
+from("master:ns:timer:test?period=100").log("Timer invoked on a single JVM at 
a time");
+```
+
+It's possible to enable the file cluster service with a property like below:
+
+```
+quarkus.camel.cluster.file.enabled = true
+```
+
+As a result, a single consumer will be active across the `ns` camel master 
namespace.
+It means that, at a given time, only a single timer will generate exchanges 
across all JVMs.
+In other words, messages will be logged every 100ms on a single JVM at a time.
+
+The file cluster service could further be tuned by tweaking 
`quarkus.camel.cluster.file.*` properties.
diff --git 
a/extensions/file/runtime/src/main/java/org/apache/camel/quarkus/component/file/cluster/FileLockClusterServiceConfig.java
 
b/extensions/file/runtime/src/main/java/org/apache/camel/quarkus/component/file/cluster/FileLockClusterServiceConfig.java
new file mode 100644
index 0000000000..e67c5e72bf
--- /dev/null
+++ 
b/extensions/file/runtime/src/main/java/org/apache/camel/quarkus/component/file/cluster/FileLockClusterServiceConfig.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.file.cluster;
+
+import java.util.Map;
+import java.util.Optional;
+import java.util.function.BooleanSupplier;
+
+import io.quarkus.runtime.annotations.ConfigItem;
+import io.quarkus.runtime.annotations.ConfigRoot;
+import org.eclipse.microprofile.config.ConfigProvider;
+
+@ConfigRoot(name = "camel.cluster.file")
+public class FileLockClusterServiceConfig {
+
+    /**
+     * Whether a File Lock Cluster Service should be automatically configured
+     * according to 'quarkus.camel.cluster.file.*' configurations.
+     */
+    @ConfigItem(defaultValue = "false")
+    public boolean enabled;
+
+    /**
+     * The cluster service ID (defaults to null).
+     */
+    @ConfigItem
+    public Optional<String> id;
+
+    /**
+     * The root path (defaults to null).
+     */
+    @ConfigItem
+    public Optional<String> root;
+
+    /**
+     * The service lookup order/priority (defaults to 2147482647).
+     */
+    @ConfigItem
+    public Optional<Integer> order;
+
+    /**
+     * The custom attributes associated to the service (defaults to empty map).
+     */
+    @ConfigItem
+    public Map<String, String> attributes;
+
+    /**
+     * The time to wait before starting to try to acquire lock (defaults to 
1000ms).
+     */
+    @ConfigItem
+    public Optional<String> acquireLockDelay;
+
+    /**
+     * The time to wait between attempts to try to acquire lock (defaults to 
10000ms).
+     */
+    @ConfigItem
+    public Optional<String> acquireLockInterval;
+
+    public static final class Enabled implements BooleanSupplier {
+        @Override
+        public boolean getAsBoolean() {
+            return 
ConfigProvider.getConfig().getOptionalValue("quarkus.camel.cluster.file.enabled",
 Boolean.class)
+                    .orElse(Boolean.FALSE);
+        }
+    }
+}
diff --git 
a/extensions/file/runtime/src/main/java/org/apache/camel/quarkus/component/file/cluster/FileLockClusterServiceRecorder.java
 
b/extensions/file/runtime/src/main/java/org/apache/camel/quarkus/component/file/cluster/FileLockClusterServiceRecorder.java
new file mode 100644
index 0000000000..5744961c5d
--- /dev/null
+++ 
b/extensions/file/runtime/src/main/java/org/apache/camel/quarkus/component/file/cluster/FileLockClusterServiceRecorder.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.file.cluster;
+
+import java.util.concurrent.TimeUnit;
+
+import io.quarkus.runtime.RuntimeValue;
+import io.quarkus.runtime.annotations.Recorder;
+import org.apache.camel.catalog.impl.TimePatternConverter;
+import org.apache.camel.component.file.cluster.FileLockClusterService;
+
+@Recorder
+public class FileLockClusterServiceRecorder {
+
+    public RuntimeValue<FileLockClusterService> 
createFileLockClusterService(FileLockClusterServiceConfig config) {
+        FileLockClusterService flcs = new FileLockClusterService();
+
+        config.id.ifPresent(id -> flcs.setId(id));
+        config.root.ifPresent(root -> flcs.setRoot(root));
+        config.order.ifPresent(order -> flcs.setOrder(order));
+        config.acquireLockDelay.ifPresent(delay -> {
+            
flcs.setAcquireLockDelay(TimePatternConverter.toMilliSeconds(delay), 
TimeUnit.MILLISECONDS);
+        });
+        config.acquireLockInterval.ifPresent(interval -> {
+            
flcs.setAcquireLockInterval(TimePatternConverter.toMilliSeconds(interval), 
TimeUnit.MILLISECONDS);
+        });
+
+        config.attributes.forEach((key, value) -> {
+            flcs.setAttribute(key, value);
+        });
+
+        return new RuntimeValue<FileLockClusterService>(flcs);
+    }
+
+}
diff --git a/extensions/master/runtime/src/main/doc/configuration.adoc 
b/extensions/master/runtime/src/main/doc/configuration.adoc
index 8fa5657956..ad818766dd 100644
--- a/extensions/master/runtime/src/main/doc/configuration.adoc
+++ b/extensions/master/runtime/src/main/doc/configuration.adoc
@@ -1,3 +1,4 @@
 This extension can be used in conjunction with extensions below:
 
+* xref:reference/extensions/file.adoc[Camel Quarkus File]
 * xref:reference/extensions/kubernetes.adoc[Camel Quarkus Kubernetes]
\ No newline at end of file

Reply via email to