This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 72c5a152a14 CAMEL-20244: camel-core - Supervising route controller
should default be DOWN during restarting and exhaust phase (#14194)
72c5a152a14 is described below
commit 72c5a152a14767aaedaa2acc146cafbef51b4905
Author: Claus Ibsen <[email protected]>
AuthorDate: Mon May 20 09:27:20 2024 +0200
CAMEL-20244: camel-core - Supervising route controller should default be
DOWN during restarting and exhaust phase (#14194)
---
.../main/camel-main-configuration-metadata.json | 4 ++--
.../camel/spi/SupervisingRouteController.java | 22 +++++------------
.../engine/DefaultSupervisingRouteController.java | 4 ++--
.../camel-main-configuration-metadata.json | 4 ++--
core/camel-main/src/main/docs/main.adoc | 4 ++--
.../RouteControllerConfigurationProperties.java | 28 ++++++++++------------
.../ROOT/pages/camel-4x-upgrade-guide-4_7.adoc | 4 ++++
.../modules/ROOT/pages/route-controller.adoc | 8 ++++---
8 files changed, 35 insertions(+), 43 deletions(-)
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json
index 3ed4a3937f0..fd96d560fb5 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json
@@ -250,8 +250,8 @@
{ "name": "camel.routecontroller.includeRoutes", "description": "Pattern
for filtering routes to be included as supervised. The pattern is matching on
route id, and endpoint uri for the route. Multiple patterns can be separated by
comma. For example to include all kafka routes, you can say kafka:. And to
include routes with specific route ids myRoute,myOtherRoute. The pattern
supports wildcards and uses the matcher from
org.apache.camel.support.PatternHelper#matchPattern.", "sourceTy [...]
{ "name": "camel.routecontroller.initialDelay", "description": "Initial
delay in milli seconds before the route controller starts, after CamelContext
has been started.", "sourceType":
"org.apache.camel.main.RouteControllerConfigurationProperties", "type":
"integer", "javaType": "long" },
{ "name": "camel.routecontroller.threadPoolSize", "description": "The
number of threads used by the route controller scheduled thread pool that are
used for restarting routes. The pool uses 1 thread by default, but you can
increase this to allow the controller to concurrently attempt to restart
multiple routes in case more than one route has problems starting.",
"sourceType": "org.apache.camel.main.RouteControllerConfigurationProperties",
"type": "integer", "javaType": "int", "defaul [...]
- { "name": "camel.routecontroller.unhealthyOnExhausted", "description":
"Whether to mark the route as unhealthy (down) when all restarting attempts
(backoff) have failed and the route is not successfully started and the route
manager is giving up. Setting this to true allows health checks to know about
this and can report the Camel application as DOWN. The default is false.",
"sourceType": "org.apache.camel.main.RouteControllerConfigurationProperties",
"type": "boolean", "javaType": " [...]
- { "name": "camel.routecontroller.unhealthyOnRestarting", "description":
"Whether to mark the route as unhealthy (down) when the route failed to
initially start, and is being controlled for restarting (backoff). Setting this
to true allows health checks to know about this and can report the Camel
application as DOWN. The default is false.", "sourceType":
"org.apache.camel.main.RouteControllerConfigurationProperties", "type":
"boolean", "javaType": "boolean", "defaultValue": "false" },
+ { "name": "camel.routecontroller.unhealthyOnExhausted", "description":
"Whether to mark the route as unhealthy (down) when all restarting attempts
(backoff) have failed and the route is not successfully started and the route
manager is giving up. If setting this to false will make health checks ignore
this problem and allow to report the Camel application as UP.", "sourceType":
"org.apache.camel.main.RouteControllerConfigurationProperties", "type":
"boolean", "javaType": "boolean", " [...]
+ { "name": "camel.routecontroller.unhealthyOnRestarting", "description":
"Whether to mark the route as unhealthy (down) when the route failed to
initially start, and is being controlled for restarting (backoff). If setting
this to false will make health checks ignore this problem and allow to report
the Camel application as UP.", "sourceType":
"org.apache.camel.main.RouteControllerConfigurationProperties", "type":
"boolean", "javaType": "boolean", "defaultValue": true },
{ "name": "camel.server.devConsoleEnabled", "description": "Whether to
enable developer console (not intended for production use). Dev console must
also be enabled on CamelContext. For example by setting
camel.context.dev-console=true in application.properties, or via code
camelContext.setDevConsole(true); If enabled then you can access a basic
developer console on context-path: \/q\/dev.", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "boolean",
"j [...]
{ "name": "camel.server.enabled", "description": "Whether embedded HTTP
server is enabled. By default, the server is not enabled.", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "boolean",
"javaType": "boolean", "defaultValue": "false" },
{ "name": "camel.server.healthCheckEnabled", "description": "Whether to
enable health-check console. If enabled then you can access health-check status
on context-path: \/q\/health", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "boolean",
"javaType": "boolean", "defaultValue": "false" },
diff --git
a/core/camel-api/src/main/java/org/apache/camel/spi/SupervisingRouteController.java
b/core/camel-api/src/main/java/org/apache/camel/spi/SupervisingRouteController.java
index f80e8248bda..072bc06931a 100644
---
a/core/camel-api/src/main/java/org/apache/camel/spi/SupervisingRouteController.java
+++
b/core/camel-api/src/main/java/org/apache/camel/spi/SupervisingRouteController.java
@@ -108,25 +108,16 @@ public interface SupervisingRouteController extends
RouteController {
*/
void setBackOffMultiplier(double backOffMultiplier);
- /**
- * Whether to mark the route as unhealthy (down) when all restarting
attempts (backoff) have failed and the route is
- * not successfully started and the route manager is giving up.
- *
- * Setting this to true allows health checks to know about this and can
report the Camel application as DOWN.
- *
- * The default is false.
- */
- void setUnhealthyOnExhausted(boolean unhealthyOnExhausted);
+ boolean isUnhealthyOnExhausted();
/**
* Whether to mark the route as unhealthy (down) when all restarting
attempts (backoff) have failed and the route is
* not successfully started and the route manager is giving up.
*
- * Setting this to true allows health checks to know about this and can
report the Camel application as DOWN.
- *
- * The default is false.
+ * If setting this to false will make health checks ignore this problem
and allow to report the Camel application as
+ * UP.
*/
- boolean isUnhealthyOnExhausted();
+ void setUnhealthyOnExhausted(boolean unhealthyOnExhausted);
boolean isUnhealthyOnRestarting();
@@ -134,9 +125,8 @@ public interface SupervisingRouteController extends
RouteController {
* Whether to mark the route as unhealthy (down) when the route failed to
initially start, and is being controlled
* for restarting (backoff).
*
- * Setting this to true allows health checks to know about this and can
report the Camel application as DOWN.
- *
- * The default is false.
+ * If setting this to false will make health checks ignore this problem
and allow to report the Camel application as
+ * UP.
*/
void setUnhealthyOnRestarting(boolean unhealthyOnRestarting);
diff --git
a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultSupervisingRouteController.java
b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultSupervisingRouteController.java
index 0bc50175510..22b5c68527a 100644
---
a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultSupervisingRouteController.java
+++
b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultSupervisingRouteController.java
@@ -88,8 +88,8 @@ public class DefaultSupervisingRouteController extends
DefaultRouteController im
private long backOffMaxElapsedTime;
private long backOffMaxAttempts;
private double backOffMultiplier = 1.0d;
- private boolean unhealthyOnExhausted;
- private boolean unhealthyOnRestarting;
+ private boolean unhealthyOnExhausted = true;
+ private boolean unhealthyOnRestarting = true;
public DefaultSupervisingRouteController() {
this.lock = new Object();
diff --git
a/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
b/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
index 3ed4a3937f0..fd96d560fb5 100644
---
a/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
+++
b/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
@@ -250,8 +250,8 @@
{ "name": "camel.routecontroller.includeRoutes", "description": "Pattern
for filtering routes to be included as supervised. The pattern is matching on
route id, and endpoint uri for the route. Multiple patterns can be separated by
comma. For example to include all kafka routes, you can say kafka:. And to
include routes with specific route ids myRoute,myOtherRoute. The pattern
supports wildcards and uses the matcher from
org.apache.camel.support.PatternHelper#matchPattern.", "sourceTy [...]
{ "name": "camel.routecontroller.initialDelay", "description": "Initial
delay in milli seconds before the route controller starts, after CamelContext
has been started.", "sourceType":
"org.apache.camel.main.RouteControllerConfigurationProperties", "type":
"integer", "javaType": "long" },
{ "name": "camel.routecontroller.threadPoolSize", "description": "The
number of threads used by the route controller scheduled thread pool that are
used for restarting routes. The pool uses 1 thread by default, but you can
increase this to allow the controller to concurrently attempt to restart
multiple routes in case more than one route has problems starting.",
"sourceType": "org.apache.camel.main.RouteControllerConfigurationProperties",
"type": "integer", "javaType": "int", "defaul [...]
- { "name": "camel.routecontroller.unhealthyOnExhausted", "description":
"Whether to mark the route as unhealthy (down) when all restarting attempts
(backoff) have failed and the route is not successfully started and the route
manager is giving up. Setting this to true allows health checks to know about
this and can report the Camel application as DOWN. The default is false.",
"sourceType": "org.apache.camel.main.RouteControllerConfigurationProperties",
"type": "boolean", "javaType": " [...]
- { "name": "camel.routecontroller.unhealthyOnRestarting", "description":
"Whether to mark the route as unhealthy (down) when the route failed to
initially start, and is being controlled for restarting (backoff). Setting this
to true allows health checks to know about this and can report the Camel
application as DOWN. The default is false.", "sourceType":
"org.apache.camel.main.RouteControllerConfigurationProperties", "type":
"boolean", "javaType": "boolean", "defaultValue": "false" },
+ { "name": "camel.routecontroller.unhealthyOnExhausted", "description":
"Whether to mark the route as unhealthy (down) when all restarting attempts
(backoff) have failed and the route is not successfully started and the route
manager is giving up. If setting this to false will make health checks ignore
this problem and allow to report the Camel application as UP.", "sourceType":
"org.apache.camel.main.RouteControllerConfigurationProperties", "type":
"boolean", "javaType": "boolean", " [...]
+ { "name": "camel.routecontroller.unhealthyOnRestarting", "description":
"Whether to mark the route as unhealthy (down) when the route failed to
initially start, and is being controlled for restarting (backoff). If setting
this to false will make health checks ignore this problem and allow to report
the Camel application as UP.", "sourceType":
"org.apache.camel.main.RouteControllerConfigurationProperties", "type":
"boolean", "javaType": "boolean", "defaultValue": true },
{ "name": "camel.server.devConsoleEnabled", "description": "Whether to
enable developer console (not intended for production use). Dev console must
also be enabled on CamelContext. For example by setting
camel.context.dev-console=true in application.properties, or via code
camelContext.setDevConsole(true); If enabled then you can access a basic
developer console on context-path: \/q\/dev.", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "boolean",
"j [...]
{ "name": "camel.server.enabled", "description": "Whether embedded HTTP
server is enabled. By default, the server is not enabled.", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "boolean",
"javaType": "boolean", "defaultValue": "false" },
{ "name": "camel.server.healthCheckEnabled", "description": "Whether to
enable health-check console. If enabled then you can access health-check status
on context-path: \/q\/health", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "boolean",
"javaType": "boolean", "defaultValue": "false" },
diff --git a/core/camel-main/src/main/docs/main.adoc
b/core/camel-main/src/main/docs/main.adoc
index 794dfb33e63..18de5cf72e7 100644
--- a/core/camel-main/src/main/docs/main.adoc
+++ b/core/camel-main/src/main/docs/main.adoc
@@ -160,8 +160,8 @@ The camel.routecontroller supports 12 options, which are
listed below.
| *camel.routecontroller.include{zwsp}Routes* | Pattern for filtering routes
to be included as supervised. The pattern is matching on route id, and endpoint
uri for the route. Multiple patterns can be separated by comma. For example to
include all kafka routes, you can say kafka:. And to include routes with
specific route ids myRoute,myOtherRoute. The pattern supports wildcards and
uses the matcher from org.apache.camel.support.PatternHelper#matchPattern. | |
String
| *camel.routecontroller.initial{zwsp}Delay* | Initial delay in milli seconds
before the route controller starts, after CamelContext has been started. | |
long
| *camel.routecontroller.thread{zwsp}PoolSize* | The number of threads used by
the route controller scheduled thread pool that are used for restarting routes.
The pool uses 1 thread by default, but you can increase this to allow the
controller to concurrently attempt to restart multiple routes in case more than
one route has problems starting. | 1 | int
-| *{zwsp}camel.routecontroller.unhealthy{zwsp}OnExhausted* | Whether to mark
the route as unhealthy (down) when all restarting attempts (backoff) have
failed and the route is not successfully started and the route manager is
giving up. Setting this to true allows health checks to know about this and can
report the Camel application as DOWN. The default is false. | false | boolean
-| *{zwsp}camel.routecontroller.unhealthy{zwsp}OnRestarting* | Whether to mark
the route as unhealthy (down) when the route failed to initially start, and is
being controlled for restarting (backoff). Setting this to true allows health
checks to know about this and can report the Camel application as DOWN. The
default is false. | false | boolean
+| *{zwsp}camel.routecontroller.unhealthy{zwsp}OnExhausted* | Whether to mark
the route as unhealthy (down) when all restarting attempts (backoff) have
failed and the route is not successfully started and the route manager is
giving up. If setting this to false will make health checks ignore this problem
and allow to report the Camel application as UP. | true | boolean
+| *{zwsp}camel.routecontroller.unhealthy{zwsp}OnRestarting* | Whether to mark
the route as unhealthy (down) when the route failed to initially start, and is
being controlled for restarting (backoff). If setting this to false will make
health checks ignore this problem and allow to report the Camel application as
UP. | true | boolean
|===
diff --git
a/core/camel-main/src/main/java/org/apache/camel/main/RouteControllerConfigurationProperties.java
b/core/camel-main/src/main/java/org/apache/camel/main/RouteControllerConfigurationProperties.java
index 89681269db0..904b009e47b 100644
---
a/core/camel-main/src/main/java/org/apache/camel/main/RouteControllerConfigurationProperties.java
+++
b/core/camel-main/src/main/java/org/apache/camel/main/RouteControllerConfigurationProperties.java
@@ -34,10 +34,10 @@ public class RouteControllerConfigurationProperties
implements BootstrapCloseabl
private String includeRoutes;
@Metadata
private String excludeRoutes;
- @Metadata
- private boolean unhealthyOnExhausted;
- @Metadata
- private boolean unhealthyOnRestarting;
+ @Metadata(label = "advanced", defaultValue = "true")
+ private boolean unhealthyOnExhausted = true;
+ @Metadata(label = "advanced", defaultValue = "true")
+ private boolean unhealthyOnRestarting = true;
@Metadata
private long initialDelay;
@Metadata(defaultValue = "2000")
@@ -206,9 +206,8 @@ public class RouteControllerConfigurationProperties
implements BootstrapCloseabl
* Whether to mark the route as unhealthy (down) when all restarting
attempts (backoff) have failed and the route is
* not successfully started and the route manager is giving up.
*
- * Setting this to true allows health checks to know about this and can
report the Camel application as DOWN.
- *
- * The default is false.
+ * If setting this to false will make health checks ignore this problem
and allow to report the Camel application as
+ * UP.
*/
public void setUnhealthyOnExhausted(boolean unhealthyOnExhausted) {
this.unhealthyOnExhausted = unhealthyOnExhausted;
@@ -222,9 +221,8 @@ public class RouteControllerConfigurationProperties
implements BootstrapCloseabl
* Whether to mark the route as unhealthy (down) when the route failed to
initially start, and is being controlled
* for restarting (backoff).
*
- * Setting this to true allows health checks to know about this and can
report the Camel application as DOWN.
- *
- * The default is false.
+ * If setting this to false will make health checks ignore this problem
and allow to report the Camel application as
+ * UP.
*/
public void setUnhealthyOnRestarting(boolean unhealthyOnRestarting) {
this.unhealthyOnRestarting = unhealthyOnRestarting;
@@ -336,9 +334,8 @@ public class RouteControllerConfigurationProperties
implements BootstrapCloseabl
* Whether to mark the route as unhealthy (down) when all restarting
attempts (backoff) have failed and the route is
* not successfully started and the route manager is giving up.
*
- * Setting this to true allows health checks to know about this and can
report the Camel application as DOWN.
- *
- * The default is false.
+ * If setting this to false will make health checks ignore this problem
and allow to report the Camel application as
+ * UP.
*/
public RouteControllerConfigurationProperties
withUnhealthyOnExhausted(boolean unhealthyOnExhausted) {
this.unhealthyOnExhausted = unhealthyOnExhausted;
@@ -349,9 +346,8 @@ public class RouteControllerConfigurationProperties
implements BootstrapCloseabl
* Whether to mark the route as unhealthy (down) when the route failed to
initially start, and is being controlled
* for restarting (backoff).
*
- * Setting this to true allows health checks to know about this and can
report the Camel application as DOWN.
- *
- * The default is false.
+ * If setting this to false will make health checks ignore this problem
and allow to report the Camel application as
+ * UP.
*/
public RouteControllerConfigurationProperties
withUnhealthyOnRestarting(boolean unhealthyOnRestarting) {
this.unhealthyOnRestarting = unhealthyOnRestarting;
diff --git
a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_7.adoc
b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_7.adoc
index 995b4c0b44f..8cd93c737aa 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_7.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_7.adoc
@@ -21,6 +21,10 @@ We have now implemented similar logic for the consumer
health check as well (the
Previously a route that has not been started due to `auto-startup=false` would
still have its consumer health-check being executed,
which could lead to DOWN due to consumer failing the check.
+The `SupervisingRouteController` has now been pre-configured to report `DOWN`
during restart attempts, and also when
+giving up starting a route. It is the `UnhealthyOnExhausted` and
`UnhealthyOnRestarting` options that have been changed to be default `true`.
+To have previous behavior you can set these options to `false`.
+
=== DSL
The Load Balancer EIP has aligned naming and the following balancers has been
renamed in XML and YAML DSL:
diff --git a/docs/user-manual/modules/ROOT/pages/route-controller.adoc
b/docs/user-manual/modules/ROOT/pages/route-controller.adoc
index 62b85392a2b..b70aa90e8e1 100644
--- a/docs/user-manual/modules/ROOT/pages/route-controller.adoc
+++ b/docs/user-manual/modules/ROOT/pages/route-controller.adoc
@@ -121,7 +121,7 @@ You can configure the `SupervisingRouteController` using
the following options:
|=======================================================================
| Option | Default | Description
| Enabled | `false` | To enable using supervising route controller which
allows Camel to startup and then the controller takes care of starting the
routes in a safe manner. This can be used when you want to startup Camel
despite a route may otherwise fail fast during startup and cause Camel to fail
to startup as well. By delegating the route startup to the supervising route
controller then its manages the startup using a background thread. The
controller allows to be configured with vari [...]
-| InitialDelay | | Initial delay in milli seconds before the route controller
starts, after CamelContext has been started.
+| InitialDelay | | Initial delay in milliseconds before the route controller
starts, after CamelContext has been started.
| BackOffDelay | `2000` | Backoff delay in millis when restarting a route that
failed to startup.
| BackOffMaxAttempts | | Backoff maximum number of attempts to restart a route
that failed to startup. When this threshold has been exceeded then the
controller will give up attempting to restart the route, and the route will
remain as stopped. Will by default attempt forever.
| BackOffMaxDelay | | Backoff maximum delay in millis when restarting a route
that failed to startup.
@@ -130,10 +130,12 @@ You can configure the `SupervisingRouteController` using
the following options:
| IncludeRoutes | | Pattern for filtering routes to be included as supervised.
The pattern is matching on route id, and endpoint uri for the route. Multiple
patterns can be separated by comma. For example to include all kafka routes,
you can say kafka:. And to include routes with specific route ids
myRoute,myOtherRoute. The pattern supports wildcards and uses the matcher from
org.apache.camel.support.PatternHelper#matchPattern.
| ExcludeRoutes | | Pattern for filtering routes to be excluded as supervised.
The pattern is matching on route id, and endpoint uri for the route. Multiple
patterns can be separated by comma. For example to exclude all JMS routes, you
can say jms:. And to exclude routes with specific route ids
mySpecialRoute,myOtherSpecialRoute. The pattern supports wildcards and uses the
matcher from org.apache.camel.support.PatternHelper#matchPattern.
| ThreadPoolSize | `1` | The number of threads used by the route controller
scheduled thread pool that are used for restarting routes. The pool uses 1
thread by default, but you can increase this to allow the controller to
concurrently attempt to restart multiple routes in case more than one route has
problems starting.
-| UnhealthyOnExhausted | `false` | Whether to mark the route as unhealthy
(down) when all restarting attempts (backoff) have failed and the route is not
successfully started and the route manager is giving up. Setting this to true
allows health checks to know about this and can report the Camel application as
DOWN.
-| UnhealthyOnRestarting | `false` | Whether to mark the route as unhealthy
(down) when the route failed to initially start, and is being controlled for
restarting (backoff). Setting this to true allows health checks to know about
this and can report the Camel application as DOWN.
+| UnhealthyOnExhausted | `true` | Whether to mark the route as unhealthy
(down) when all restarting attempts (backoff) have failed and the route is not
successfully started and the route manager is giving up. If setting this to
false will make health checks ignore this problem and allow to report the Camel
application as UP.
+| UnhealthyOnRestarting | `true` | Whether to mark the route as unhealthy
(down) when the route failed to initially start, and is being controlled for
restarting (backoff). If setting this to false will make health checks ignore
this problem and allow to report the Camel application as UP.
|=======================================================================
+IMPORTANT: The `UnhealthyOnExhausted` and `UnhealthyOnRestarting` options are
default `false` in Camel 4.6 or older.
+
=== Filtering routes to fail fast
When using supervising route controller, then all routes would by default be
supervised