Skip to content
Merged
52 changes: 31 additions & 21 deletions core/camel-spring-boot/src/main/docs/spring-boot.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -2036,6 +2033,19 @@
"description": "Specify the username to access IBM Event Stream",
"sourceType": "org.apache.camel.spring.boot.vault.IBMVaultConfigurationProperties"
},
{
"name": "camel.vault.ibm.refresh-enabled",
"type": "java.lang.Boolean",
"description": "Whether to automatically refresh the secrets on update",
"sourceType": "org.apache.camel.spring.boot.vault.IBMVaultConfigurationProperties",
"defaultValue": false
},
{
"name": "camel.vault.ibm.secrets",
"type": "java.lang.String",
"description": "Define the secrets to look at",
"sourceType": "org.apache.camel.spring.boot.vault.IBMVaultConfigurationProperties"
},
{
"name": "camel.vault.ibm.service-url",
"type": "java.lang.String",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -482,8 +482,8 @@ CamelBeanPostProcessor camelBeanPostProcessor(ApplicationContext applicationCont
StartupConditionStrategy startupConditionStrategy(CamelStartupConditionConfigurationProperties config) {
StartupConditionStrategy scs = new DefaultStartupConditionStrategy();
scs.setEnabled(config.isEnabled());
scs.setInterval(config.getInterval());
scs.setTimeout(config.getTimeout());
scs.setInterval(Math.toIntExact(config.getInterval().toMillis()));
scs.setTimeout(Math.toIntExact(config.getTimeout().toMillis()));
scs.setOnTimeout(config.getOnTimeout());
String envExist = config.getEnvironmentVariableExists();
if (envExist != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,9 @@
package org.apache.camel.spring.boot;

import org.apache.camel.CamelContext;
import org.apache.camel.main.MainListener;
import org.apache.camel.main.MainShutdownStrategy;
import org.springframework.context.ApplicationContext;

import java.util.Map;

/**
* Controller to keep the main running and perform graceful shutdown when the JVM is stopped.
*/
Expand All @@ -32,15 +29,12 @@ public class CamelMainRunController {
private final Thread daemon;

public CamelMainRunController(ApplicationContext applicationContext, CamelContext camelContext) {
controller = new CamelSpringBootApplicationController(applicationContext);
// do not register the MainListener beans on this controller: they are already notified
// via the controller created by CamelAutoConfiguration, and this Main is only used
// to keep the JVM running
controller = new CamelSpringBootApplicationController(applicationContext, false);
controller.setCamelContext(camelContext);

// setup main listeners eager on controller
final Map<String, MainListener> listeners = applicationContext.getBeansOfType(MainListener.class);
for (MainListener listener : listeners.values()) {
controller.getMain().addMainListener(listener);
}

daemon = new Thread(new DaemonTask(), "CamelMainRunController");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,24 @@ public class CamelSpringBootApplicationController implements CamelContextAware {
private CamelContext camelContext;

public CamelSpringBootApplicationController(final ApplicationContext applicationContext) {
this(applicationContext, true);
}

/**
* @param registerMainListeners whether to register the {@link MainListener} beans from the application context on
* the internal {@link Main}. The controller used by the main run controller must not
* register them, as the listeners are already notified via the controller created by
* {@link CamelAutoConfiguration}, and registering them on both would notify each
* listener twice.
*/
CamelSpringBootApplicationController(final ApplicationContext applicationContext, boolean registerMainListeners) {
this.main = new CamelSpringMain(applicationContext, this);
// inject main listeners
final Map<String, MainListener> listeners = applicationContext.getBeansOfType(MainListener.class);
for (MainListener listener : listeners.values()) {
this.main.addMainListener(listener);
if (registerMainListeners) {
// inject main listeners
final Map<String, MainListener> listeners = applicationContext.getBeansOfType(MainListener.class);
for (MainListener listener : listeners.values()) {
this.main.addMainListener(listener);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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.
Expand Down Expand Up @@ -69,19 +75,19 @@ public void setEnabled(boolean enabled) {
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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import org.apache.camel.CamelContext;
import org.apache.camel.spring.boot.CamelAutoConfiguration;
import org.apache.camel.spring.boot.actuate.endpoint.CamelRouteControllerEndpoint;
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnAvailableEndpoint;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBooleanProperty;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;

@AutoConfiguration(before = CamelAutoConfiguration.class)
@ConditionalOnProperty(prefix = "camel.clustered.controller", name = "enabled")
@ConditionalOnBooleanProperty("camel.clustered.controller.enabled")
@EnableConfigurationProperties(ClusteredRouteControllerConfiguration.class)
public class ClusteredRouteControllerAutoConfiguration {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,6 @@ public class ClusteredRouteControllerConfiguration {
*/
private String namespace;

/**
* The reference to a cluster service.
*/
private String clusterServiceRef;

/**
* The cluster service.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ public class CamelErrorRegistryAutoConfiguration {
@Bean
public ErrorRegistry errorRegistry(CamelContext camelContext, CamelErrorRegistryConfigurationProperties config) {
// dev profile enables error registry to capture routing errors for tooling (TUI)
if (!config.isEnabled() && "dev".equals(camelContext.getCamelContextExtension().getProfile())) {
config.setEnabled(true);
}
if (!config.isEnabled()) {
// (do not mutate the shared configuration properties bean)
boolean enabled = config.isEnabled()
|| "dev".equals(camelContext.getCamelContextExtension().getProfile());
if (!enabled) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,58 +17,53 @@
package org.apache.camel.spring.boot.routecontroller;

import org.apache.camel.impl.engine.DefaultSupervisingRouteController;
import org.apache.camel.spi.RouteController;
import org.apache.camel.spi.SupervisingRouteController;
import org.apache.camel.spring.boot.CamelAutoConfiguration;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBooleanProperty;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;

@AutoConfiguration(before = CamelAutoConfiguration.class)
@ConditionalOnProperty(prefix = "camel.routecontroller", name = "enabled")
@ConditionalOnBooleanProperty("camel.routecontroller.enabled")
@EnableConfigurationProperties(SupervisingRouteControllerConfiguration.class)
public class SupervisingRouteControllerAutoConfiguration {

@Bean
@ConditionalOnMissingBean
public SupervisingRouteController supervisingRouteController(SupervisingRouteControllerConfiguration config) {
SupervisingRouteController src = null;

if (config.isEnabled()) {
// switch to supervising route controller
src = new DefaultSupervisingRouteController();
if (config.getIncludeRoutes() != null) {
src.setIncludeRoutes(config.getIncludeRoutes());
}
if (config.getExcludeRoutes() != null) {
src.setExcludeRoutes(config.getExcludeRoutes());
}
if (config.getThreadPoolSize() > 0) {
src.setThreadPoolSize(config.getThreadPoolSize());
}
if (config.getBackOffDelay() > 0) {
src.setBackOffDelay(config.getBackOffDelay());
}
if (config.getInitialDelay() > 0) {
src.setInitialDelay(config.getInitialDelay());
}
if (config.getBackOffMaxAttempts() > 0) {
src.setBackOffMaxAttempts(config.getBackOffMaxAttempts());
}
if (config.getBackOffMaxDelay() > 0) {
src.setBackOffMaxDelay(config.getBackOffMaxDelay());
}
if (config.getBackOffMaxElapsedTime() > 0) {
src.setBackOffMaxElapsedTime(config.getBackOffMaxElapsedTime());
}
if (config.getBackOffMultiplier() > 0) {
src.setBackOffMultiplier(config.getBackOffMultiplier());
}
src.setUnhealthyOnExhausted(config.isUnhealthyOnExhausted());
src.setUnhealthyOnRestarting(config.isUnhealthyOnRestarting());
// switch to supervising route controller
SupervisingRouteController src = new DefaultSupervisingRouteController();
if (config.getIncludeRoutes() != null) {
src.setIncludeRoutes(config.getIncludeRoutes());
}
if (config.getExcludeRoutes() != null) {
src.setExcludeRoutes(config.getExcludeRoutes());
}
if (config.getThreadPoolSize() > 0) {
src.setThreadPoolSize(config.getThreadPoolSize());
}
if (config.getBackOffDelay() != null && config.getBackOffDelay().toMillis() > 0) {
src.setBackOffDelay(config.getBackOffDelay().toMillis());
}
if (config.getInitialDelay() != null && config.getInitialDelay().toMillis() > 0) {
src.setInitialDelay(config.getInitialDelay().toMillis());
}
if (config.getBackOffMaxAttempts() > 0) {
src.setBackOffMaxAttempts(config.getBackOffMaxAttempts());
}
if (config.getBackOffMaxDelay() != null && config.getBackOffMaxDelay().toMillis() > 0) {
src.setBackOffMaxDelay(config.getBackOffMaxDelay().toMillis());
}
if (config.getBackOffMaxElapsedTime() != null && config.getBackOffMaxElapsedTime().toMillis() > 0) {
src.setBackOffMaxElapsedTime(config.getBackOffMaxElapsedTime().toMillis());
}
if (config.getBackOffMultiplier() > 0) {
src.setBackOffMultiplier(config.getBackOffMultiplier());
}
src.setUnhealthyOnExhausted(config.isUnhealthyOnExhausted());
src.setUnhealthyOnRestarting(config.isUnhealthyOnRestarting());

return src;
}
Expand Down
Loading
Loading