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

Croway pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-spring-boot.git

commit 8f24078818bca32bbf08aa6924ddff395b1e8eaa
Author: croway <[email protected]>
AuthorDate: Fri Jul 10 18:32:50 2026 +0200

    CAMEL-24000: camel-spring-boot - bind duration properties as 
java.time.Duration
    
    Convert the raw millisecond long/int properties of the supervising route
    controller (initial-delay, back-off-delay, back-off-max-delay,
    back-off-max-elapsed-time) and the startup conditions (interval, timeout)
    to java.time.Duration with @DurationUnit(MILLIS). Existing plain-number
    values keep meaning milliseconds; users can now also write readable values
    such as 5s or 2m.
    
    The clustered route controller initial-delay keeps its String type on
    purpose: it accepts Camel time patterns (via TimePatternConverter) that
    Duration binding does not support, so converting it would break existing
    configurations.
    
    Co-Authored-By: Claude Fable 5 <[email protected]>
---
 .../src/main/docs/spring-boot.json                 | 39 +++++++++----------
 .../camel/spring/boot/CamelAutoConfiguration.java  |  4 +-
 ...melStartupConditionConfigurationProperties.java | 22 +++++++----
 ...upervisingRouteControllerAutoConfiguration.java | 16 ++++----
 .../SupervisingRouteControllerConfiguration.java   | 44 +++++++++++++---------
 5 files changed, 69 insertions(+), 56 deletions(-)

diff --git a/core/camel-spring-boot/src/main/docs/spring-boot.json 
b/core/camel-spring-boot/src/main/docs/spring-boot.json
index 8639a13ba8f..85836fd4ea6 100644
--- a/core/camel-spring-boot/src/main/docs/spring-boot.json
+++ b/core/camel-spring-boot/src/main/docs/spring-boot.json
@@ -1208,10 +1208,10 @@
     },
     {
       "name": "camel.routecontroller.back-off-delay",
-      "type": "java.lang.Long",
-      "description": "Backoff delay in millis when restarting a route that 
failed to startup.",
+      "type": "java.time.Duration",
+      "description": "Backoff delay when restarting a route that failed to 
startup. Plain numbers are treated as milliseconds.",
       "sourceType": 
"org.apache.camel.spring.boot.routecontroller.SupervisingRouteControllerConfiguration",
-      "defaultValue": 2000
+      "defaultValue": "2000ms"
     },
     {
       "name": "camel.routecontroller.back-off-max-attempts",
@@ -1222,17 +1222,15 @@
     },
     {
       "name": "camel.routecontroller.back-off-max-delay",
-      "type": "java.lang.Long",
-      "description": "Backoff maximum delay in millis when restarting a route 
that failed to startup.",
-      "sourceType": 
"org.apache.camel.spring.boot.routecontroller.SupervisingRouteControllerConfiguration",
-      "defaultValue": 0
+      "type": "java.time.Duration",
+      "description": "Backoff maximum delay when restarting a route that 
failed to startup. Plain numbers are treated as milliseconds.",
+      "sourceType": 
"org.apache.camel.spring.boot.routecontroller.SupervisingRouteControllerConfiguration"
     },
     {
       "name": "camel.routecontroller.back-off-max-elapsed-time",
-      "type": "java.lang.Long",
-      "description": "Backoff maximum elapsed time in millis, after which the 
backoff should be considered exhausted and no more attempts should be made.",
-      "sourceType": 
"org.apache.camel.spring.boot.routecontroller.SupervisingRouteControllerConfiguration",
-      "defaultValue": 0
+      "type": "java.time.Duration",
+      "description": "Backoff maximum elapsed time, after which the backoff 
should be considered exhausted and no more attempts should be made. Plain 
numbers are treated as milliseconds.",
+      "sourceType": 
"org.apache.camel.spring.boot.routecontroller.SupervisingRouteControllerConfiguration"
     },
     {
       "name": "camel.routecontroller.back-off-multiplier",
@@ -1262,10 +1260,9 @@
     },
     {
       "name": "camel.routecontroller.initial-delay",
-      "type": "java.lang.Long",
-      "description": "Initial delay in milli seconds before the route 
controller starts, after CamelContext has been started.",
-      "sourceType": 
"org.apache.camel.spring.boot.routecontroller.SupervisingRouteControllerConfiguration",
-      "defaultValue": 0
+      "type": "java.time.Duration",
+      "description": "Initial delay before the route controller starts, after 
CamelContext has been started. Plain numbers are treated as milliseconds.",
+      "sourceType": 
"org.apache.camel.spring.boot.routecontroller.SupervisingRouteControllerConfiguration"
     },
     {
       "name": "camel.routecontroller.thread-pool-size",
@@ -1473,10 +1470,10 @@
     },
     {
       "name": "camel.startupcondition.interval",
-      "type": "java.lang.Integer",
-      "description": "Interval in millis between checking conditions.",
+      "type": "java.time.Duration",
+      "description": "Interval between checking conditions. Plain numbers are 
treated as milliseconds.",
       "sourceType": 
"org.apache.camel.spring.boot.CamelStartupConditionConfigurationProperties",
-      "defaultValue": 500
+      "defaultValue": "500ms"
     },
     {
       "name": "camel.startupcondition.on-timeout",
@@ -1487,10 +1484,10 @@
     },
     {
       "name": "camel.startupcondition.timeout",
-      "type": "java.lang.Integer",
-      "description": "Total timeout (in millis) for all startup conditions.",
+      "type": "java.time.Duration",
+      "description": "Total timeout for all startup conditions. Plain numbers 
are treated as milliseconds.",
       "sourceType": 
"org.apache.camel.spring.boot.CamelStartupConditionConfigurationProperties",
-      "defaultValue": 20000
+      "defaultValue": "20000ms"
     },
     {
       "name": "camel.threadpool.allow-core-thread-time-out",
diff --git 
a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelAutoConfiguration.java
 
b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelAutoConfiguration.java
index 7dcb5965194..95b313ac908 100644
--- 
a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelAutoConfiguration.java
+++ 
b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelAutoConfiguration.java
@@ -482,8 +482,8 @@ public class CamelAutoConfiguration {
     StartupConditionStrategy 
startupConditionStrategy(CamelStartupConditionConfigurationProperties config) {
         StartupConditionStrategy scs = new DefaultStartupConditionStrategy();
         scs.setEnabled(config.isEnabled());
-        scs.setInterval(config.getInterval());
-        scs.setTimeout(config.getTimeout());
+        scs.setInterval((int) config.getInterval().toMillis());
+        scs.setTimeout((int) config.getTimeout().toMillis());
         scs.setOnTimeout(config.getOnTimeout());
         String envExist = config.getEnvironmentVariableExists();
         if (envExist != null) {
diff --git 
a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelStartupConditionConfigurationProperties.java
 
b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelStartupConditionConfigurationProperties.java
index 428dc30899e..ce69a060d24 100644
--- 
a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelStartupConditionConfigurationProperties.java
+++ 
b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelStartupConditionConfigurationProperties.java
@@ -16,8 +16,12 @@
  */
 package org.apache.camel.spring.boot;
 
+import java.time.Duration;
+import java.time.temporal.ChronoUnit;
+
 import org.apache.camel.spi.Metadata;
 import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.boot.convert.DurationUnit;
 
 @ConfigurationProperties(prefix = "camel.startupcondition")
 public class CamelStartupConditionConfigurationProperties {
@@ -28,14 +32,16 @@ public class CamelStartupConditionConfigurationProperties {
     private boolean enabled;
 
     /**
-     * Interval in millis between checking conditions.
+     * Interval between checking conditions. Plain numbers are treated as 
milliseconds.
      */
-    private int interval = 500;
+    @DurationUnit(ChronoUnit.MILLIS)
+    private Duration interval = Duration.ofMillis(500);
 
     /**
-     * Total timeout (in millis) for all startup conditions.
+     * Total timeout for all startup conditions. Plain numbers are treated as 
milliseconds.
      */
-    private int timeout = 20000;
+    @DurationUnit(ChronoUnit.MILLIS)
+    private Duration timeout = Duration.ofMillis(20000);
 
     /**
      * What action, to do on timeout.
@@ -69,19 +75,19 @@ public class CamelStartupConditionConfigurationProperties {
         this.enabled = enabled;
     }
 
-    public int getInterval() {
+    public Duration getInterval() {
         return interval;
     }
 
-    public void setInterval(int interval) {
+    public void setInterval(Duration interval) {
         this.interval = interval;
     }
 
-    public int getTimeout() {
+    public Duration getTimeout() {
         return timeout;
     }
 
-    public void setTimeout(int timeout) {
+    public void setTimeout(Duration timeout) {
         this.timeout = timeout;
     }
 
diff --git 
a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/routecontroller/SupervisingRouteControllerAutoConfiguration.java
 
b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/routecontroller/SupervisingRouteControllerAutoConfiguration.java
index fc8025c6e33..f8e169313f2 100644
--- 
a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/routecontroller/SupervisingRouteControllerAutoConfiguration.java
+++ 
b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/routecontroller/SupervisingRouteControllerAutoConfiguration.java
@@ -44,20 +44,20 @@ public class SupervisingRouteControllerAutoConfiguration {
         if (config.getThreadPoolSize() > 0) {
             src.setThreadPoolSize(config.getThreadPoolSize());
         }
-        if (config.getBackOffDelay() > 0) {
-            src.setBackOffDelay(config.getBackOffDelay());
+        if (config.getBackOffDelay() != null && 
config.getBackOffDelay().toMillis() > 0) {
+            src.setBackOffDelay(config.getBackOffDelay().toMillis());
         }
-        if (config.getInitialDelay() > 0) {
-            src.setInitialDelay(config.getInitialDelay());
+        if (config.getInitialDelay() != null && 
config.getInitialDelay().toMillis() > 0) {
+            src.setInitialDelay(config.getInitialDelay().toMillis());
         }
         if (config.getBackOffMaxAttempts() > 0) {
             src.setBackOffMaxAttempts(config.getBackOffMaxAttempts());
         }
-        if (config.getBackOffMaxDelay() > 0) {
-            src.setBackOffMaxDelay(config.getBackOffMaxDelay());
+        if (config.getBackOffMaxDelay() != null && 
config.getBackOffMaxDelay().toMillis() > 0) {
+            src.setBackOffMaxDelay(config.getBackOffMaxDelay().toMillis());
         }
-        if (config.getBackOffMaxElapsedTime() > 0) {
-            src.setBackOffMaxElapsedTime(config.getBackOffMaxElapsedTime());
+        if (config.getBackOffMaxElapsedTime() != null && 
config.getBackOffMaxElapsedTime().toMillis() > 0) {
+            
src.setBackOffMaxElapsedTime(config.getBackOffMaxElapsedTime().toMillis());
         }
         if (config.getBackOffMultiplier() > 0) {
             src.setBackOffMultiplier(config.getBackOffMultiplier());
diff --git 
a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/routecontroller/SupervisingRouteControllerConfiguration.java
 
b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/routecontroller/SupervisingRouteControllerConfiguration.java
index 14269d03cdd..fc7875349eb 100644
--- 
a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/routecontroller/SupervisingRouteControllerConfiguration.java
+++ 
b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/routecontroller/SupervisingRouteControllerConfiguration.java
@@ -16,8 +16,12 @@
  */
 package org.apache.camel.spring.boot.routecontroller;
 
+import java.time.Duration;
+import java.time.temporal.ChronoUnit;
+
 import org.apache.camel.spi.Metadata;
 import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.boot.convert.DurationUnit;
 
 @ConfigurationProperties(prefix = "camel.routecontroller")
 public class SupervisingRouteControllerConfiguration {
@@ -42,26 +46,32 @@ public class SupervisingRouteControllerConfiguration {
     int threadPoolSize = 1;
 
     /**
-     * Initial delay in milli seconds before the route controller starts, 
after CamelContext has been started.
+     * Initial delay before the route controller starts, after CamelContext 
has been started. Plain numbers are
+     * treated as milliseconds.
      */
-    long initialDelay;
+    @DurationUnit(ChronoUnit.MILLIS)
+    Duration initialDelay;
 
     /**
-     * Backoff delay in millis when restarting a route that failed to startup.
+     * Backoff delay when restarting a route that failed to startup. Plain 
numbers are treated as milliseconds.
      */
     @Metadata(defaultValue = "2000")
-    long backOffDelay = 2000;
+    @DurationUnit(ChronoUnit.MILLIS)
+    Duration backOffDelay = Duration.ofMillis(2000);
 
     /**
-     * Backoff maximum delay in millis when restarting a route that failed to 
startup.
+     * Backoff maximum delay when restarting a route that failed to startup. 
Plain numbers are treated as
+     * milliseconds.
      */
-    long backOffMaxDelay;
+    @DurationUnit(ChronoUnit.MILLIS)
+    Duration backOffMaxDelay;
 
     /**
-     * Backoff maximum elapsed time in millis, after which the backoff should 
be considered exhausted and no more
-     * attempts should be made.
+     * Backoff maximum elapsed time, after which the backoff should be 
considered exhausted and no more attempts
+     * should be made. Plain numbers are treated as milliseconds.
      */
-    long backOffMaxElapsedTime;
+    @DurationUnit(ChronoUnit.MILLIS)
+    Duration backOffMaxElapsedTime;
 
     /**
      * Backoff maximum number of attempts to restart a route that failed to 
startup. When this threshold has been
@@ -133,35 +143,35 @@ public class SupervisingRouteControllerConfiguration {
         this.threadPoolSize = threadPoolSize;
     }
 
-    public long getInitialDelay() {
+    public Duration getInitialDelay() {
         return initialDelay;
     }
 
-    public void setInitialDelay(long initialDelay) {
+    public void setInitialDelay(Duration initialDelay) {
         this.initialDelay = initialDelay;
     }
 
-    public long getBackOffDelay() {
+    public Duration getBackOffDelay() {
         return backOffDelay;
     }
 
-    public void setBackOffDelay(long backOffDelay) {
+    public void setBackOffDelay(Duration backOffDelay) {
         this.backOffDelay = backOffDelay;
     }
 
-    public long getBackOffMaxDelay() {
+    public Duration getBackOffMaxDelay() {
         return backOffMaxDelay;
     }
 
-    public void setBackOffMaxDelay(long backOffMaxDelay) {
+    public void setBackOffMaxDelay(Duration backOffMaxDelay) {
         this.backOffMaxDelay = backOffMaxDelay;
     }
 
-    public long getBackOffMaxElapsedTime() {
+    public Duration getBackOffMaxElapsedTime() {
         return backOffMaxElapsedTime;
     }
 
-    public void setBackOffMaxElapsedTime(long backOffMaxElapsedTime) {
+    public void setBackOffMaxElapsedTime(Duration backOffMaxElapsedTime) {
         this.backOffMaxElapsedTime = backOffMaxElapsedTime;
     }
 

Reply via email to