You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2025/04/04 17:49:54 UTC

(camel) branch main updated: CAMEL-21934: Additional Information Needed in ContextHealthCheck message (#17656)

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 30699ff0da8 CAMEL-21934: Additional Information Needed in ContextHealthCheck message (#17656)
30699ff0da8 is described below

commit 30699ff0da83f387f1c95b9273ed9540ec88e7ab
Author: Luigi De Masi <55...@users.noreply.github.com>
AuthorDate: Fri Apr 4 19:49:48 2025 +0200

    CAMEL-21934: Additional Information Needed in ContextHealthCheck message (#17656)
---
 .../camel/impl/health/ContextHealthCheck.java      | 37 +++++++++++++++++-----
 1 file changed, 29 insertions(+), 8 deletions(-)

diff --git a/core/camel-health/src/main/java/org/apache/camel/impl/health/ContextHealthCheck.java b/core/camel-health/src/main/java/org/apache/camel/impl/health/ContextHealthCheck.java
index 9f7c9b29a62..aed5dc79c72 100644
--- a/core/camel-health/src/main/java/org/apache/camel/impl/health/ContextHealthCheck.java
+++ b/core/camel-health/src/main/java/org/apache/camel/impl/health/ContextHealthCheck.java
@@ -20,6 +20,7 @@ import java.util.Map;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.Ordered;
+import org.apache.camel.ServiceStatus;
 import org.apache.camel.health.HealthCheckResultBuilder;
 
 /**
@@ -50,16 +51,36 @@ public final class ContextHealthCheck extends AbstractHealthCheck {
         builder.unknown();
 
         if (getCamelContext() != null) {
-            builder.detail("context.name", getCamelContext().getName());
+            ServiceStatus status = getCamelContext().getStatus();
+            byte phase = getCamelContext().getCamelContextExtension().getStatusPhase();
+            String name = getCamelContext().getName();
+
+            builder.detail("context.name", name);
             builder.detail("context.version", getCamelContext().getVersion());
-            builder.detail("context.status", getCamelContext().getStatus().name());
-            builder.detail("context.phase", getCamelContext().getCamelContextExtension().getStatusPhase());
+            builder.detail("context.status", status);
+            builder.detail("context.phase", phase);
 
-            if (getCamelContext().getStatus().isStarted()) {
-                builder.up();
-            } else {
-                // not ready also during graceful shutdown
-                builder.down();
+            switch (status) {
+                case Initializing:
+                case Initialized:
+                case Starting:
+                    builder.message(
+                            "Camel Context '" + name + "' is starting. Status: '" + status + "', Phase: '" + phase
+                                    + "'. Please wait...");
+                    builder.down();
+                    break;
+                case Started:
+                    builder.up();
+                case Stopping:
+                case Stopped:
+                case Suspending:
+                case Suspended:
+                    builder.message("Camel Context '" + name + "' is shutting down. Status: '" + status + "', Phase: '" + phase
+                                    + "'. Please check the debug log");
+                    builder.down();
+                default:
+                    builder.message("Camel Context '" + name + "' has unknown Status: " + status);
+                    builder.down();
             }
         }
     }