This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch camel-3.20.x
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-3.20.x by this push:
new eaa90821a41 CAMEL-19646: camel-health - Routes controlled by
superviser controller that is exhausted should report DOWN. (#10819)
eaa90821a41 is described below
commit eaa90821a41802f4fdb60c4b9ec370de0d07bbd9
Author: Claus Ibsen <[email protected]>
AuthorDate: Tue Jul 25 13:37:58 2023 +0200
CAMEL-19646: camel-health - Routes controlled by superviser controller that
is exhausted should report DOWN. (#10819)
---
core/camel-api/src/main/java/org/apache/camel/Route.java | 1 +
.../impl/engine/DefaultSupervisingRouteController.java | 1 +
.../org/apache/camel/impl/health/RouteHealthCheck.java | 14 +++++++++-----
3 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/core/camel-api/src/main/java/org/apache/camel/Route.java
b/core/camel-api/src/main/java/org/apache/camel/Route.java
index b2039689899..2491513ac7e 100644
--- a/core/camel-api/src/main/java/org/apache/camel/Route.java
+++ b/core/camel-api/src/main/java/org/apache/camel/Route.java
@@ -48,6 +48,7 @@ public interface Route extends RuntimeConfiguration {
String TEMPLATE_PROPERTY = "template";
String DESCRIPTION_PROPERTY = "description";
String CONFIGURATION_ID_PROPERTY = "configurationId";
+ String SUPERVISED = "supervised";
/**
* Gets the route id
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 19bb2e8cb00..224426ed443 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
@@ -826,6 +826,7 @@ public class DefaultSupervisingRouteController extends
DefaultRouteController im
if (routes.add(holder)) {
holder.get().setRouteController(DefaultSupervisingRouteController.this);
holder.get().setAutoStartup(false);
+ holder.get().getProperties().put(Route.SUPERVISED, true); //
mark route as being supervised
if (contextStarted.get()) {
LOG.debug("Context is already started: attempt to start
route {}", route.getId());
diff --git
a/core/camel-health/src/main/java/org/apache/camel/impl/health/RouteHealthCheck.java
b/core/camel-health/src/main/java/org/apache/camel/impl/health/RouteHealthCheck.java
index 8e09f570d3a..0520a0f310f 100644
---
a/core/camel-health/src/main/java/org/apache/camel/impl/health/RouteHealthCheck.java
+++
b/core/camel-health/src/main/java/org/apache/camel/impl/health/RouteHealthCheck.java
@@ -62,11 +62,8 @@ public class RouteHealthCheck extends AbstractHealthCheck {
builder.message(String.format("Route %s has status %s",
route.getId(), status.name()));
}
} else {
- if (!route.isAutoStartup()) {
- // if a route is configured to not to automatically start,
then the
- // route is always up as it is externally managed.
- builder.up();
- } else if (route.getRouteController() == null) {
+ if (route.getRouteController() == null
+ && Boolean.TRUE ==
route.getProperties().getOrDefault(Route.SUPERVISED, Boolean.FALSE)) {
// the route has no route controller which mean it may be
supervised and then failed
// all attempts and be exhausted, and if so then we are in
unknown status
@@ -76,6 +73,13 @@ public class RouteHealthCheck extends AbstractHealthCheck {
if (route.getLastError() != null &&
route.getLastError().isUnhealthy()) {
builder.down();
}
+ } else if (!route.isAutoStartup()) {
+ // if a route is configured to not to automatically start,
then the
+ // route is always up as it is externally managed.
+ builder.up();
+ } else {
+ // route in unknown state
+ builder.unknown();
}
}
}