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 389972d544c CAMEL-20773: camel-health - Consumer health checks should 
be skipped for non autoStartup routes (#14164)
389972d544c is described below

commit 389972d544cbe4368f171b5472e08a17dbe58256
Author: Claus Ibsen <claus.ib...@gmail.com>
AuthorDate: Thu May 16 09:24:54 2024 +0200

    CAMEL-20773: camel-health - Consumer health checks should be skipped for 
non autoStartup routes (#14164)
---
 .../java/org/apache/camel/impl/health/ConsumerHealthCheck.java    | 4 +++-
 .../modules/ROOT/pages/camel-4x-upgrade-guide-4_7.adoc            | 8 ++++++++
 docs/user-manual/modules/ROOT/pages/health-check.adoc             | 5 +++++
 3 files changed, 16 insertions(+), 1 deletion(-)

diff --git 
a/core/camel-health/src/main/java/org/apache/camel/impl/health/ConsumerHealthCheck.java
 
b/core/camel-health/src/main/java/org/apache/camel/impl/health/ConsumerHealthCheck.java
index 988b6a03672..bbb112111c4 100644
--- 
a/core/camel-health/src/main/java/org/apache/camel/impl/health/ConsumerHealthCheck.java
+++ 
b/core/camel-health/src/main/java/org/apache/camel/impl/health/ConsumerHealthCheck.java
@@ -48,7 +48,9 @@ public class ConsumerHealthCheck extends RouteHealthCheck {
     protected void doCallCheck(HealthCheckResultBuilder builder, Map<String, 
Object> options) {
         // only need to do consumer check if the route is UP
         boolean up = builder.state().compareTo(State.UP) == 0;
-        if (up && consumer instanceof HealthCheckAware) {
+        // if a route is configured to not to automatically start, then skip 
consumer checks
+        boolean external = route.getRouteController() == null && 
!route.isAutoStartup();
+        if (up && !external && consumer instanceof HealthCheckAware) {
             // health check is optional
             HealthCheck hc = ((HealthCheckAware) consumer).getHealthCheck();
             if (hc != null) {
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 14d8478abed..8d6c3bc79db 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
@@ -13,6 +13,14 @@ Add default values to `ThrottlingExceptionRoutePolicy` route 
policy.
 The `EndpointRegistry` interface has been slightly changed to now directly 
extends `Map<NormalizedEndpointUri, Endpoint>` 
 instead of being a parameterized type.  This may cause some compilation 
failures if the code is declaring a variable for the registry.
 
+=== camel-health
+
+Routes which has are set to **not** auto-startup are reported as UP in 
health-checks.
+We have now implemented similar logic for the consumer health check as well 
(the route and consumer health check are linked together).
+
+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.
+
 === 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/health-check.adoc 
b/docs/user-manual/modules/ROOT/pages/health-check.adoc
index 5e579814dba..baefeeb1917 100644
--- a/docs/user-manual/modules/ROOT/pages/health-check.adoc
+++ b/docs/user-manual/modules/ROOT/pages/health-check.adoc
@@ -94,6 +94,11 @@ You can specify multiple patterns (and use wildcards) such 
as:
 camel.health.exclude-pattern = myroute,foo,bar*
 ----
 
+==== Routes that are not automatically started
+
+If a route is configured to not to automatically start (`autoStartup=false`),
+then the route and its corresponding consumer health checks is always up as it 
is externally managed.
+
 === Turning off consumer level health-checks
 
 If routes health check is enabled then they will execute consumer 
health-checks as well

Reply via email to