davsclaus commented on code in PR #1010:
URL: 
https://github.com/apache/camel-spring-boot/pull/1010#discussion_r1397302935


##########
core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/health/CamelAvailabilityCheckAutoConfiguration.java:
##########
@@ -0,0 +1,34 @@
+package org.apache.camel.spring.boot.actuate.health;

Review Comment:
   Add license header



##########
core/camel-spring-boot/src/main/docs/spring-boot.adoc:
##########
@@ -416,3 +416,24 @@ implementing your custom 
https://docs.spring.io/spring-boot/docs/current/referen
 or by providing GraalVM JSON hint files that can be generated by the 
https://docs.spring.io/spring-boot/docs/current/reference/html/native-image.html#native-image.advanced.using-the-tracing-agent[Tracing
 Agent].
 
 For more details about `GraalVM Native Image Support` in Spring Boot please 
refer to 
https://docs.spring.io/spring-boot/docs/current/reference/html/native-image.html
+
+== Camel Readiness and Liveness State Indicators
+
+Camel specific Readiness and Liveness checks can be added to a Spring Boot 3 
application including respectively in the
+readiness and livenss groups camelLivenessStateHealthIndicator and 
camelReadinessStateHealthIndicator. In particular:
+
+[source,properties]
+----
+management.endpoint.health.group.liveness.include=livenessState,camelLivenessState
+management.endpoint.health.group.readiness.include=readinessState,camelReadinessState
+----
+
+Using camel specific readiness and liveness health indicators, the probes will 
be augmented with camel components

Review Comment:
   Use upper case Camel



##########
core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/health/readiness/CamelReadinessStateHealthIndicator.java:
##########
@@ -0,0 +1,51 @@
+package org.apache.camel.spring.boot.actuate.health.readiness;

Review Comment:
   Add license header



##########
core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/health/readiness/CamelReadinessStateHealthIndicator.java:
##########
@@ -0,0 +1,51 @@
+package org.apache.camel.spring.boot.actuate.health.readiness;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.health.HealthCheck;
+import org.apache.camel.health.HealthCheckHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import 
org.springframework.boot.actuate.availability.ReadinessStateHealthIndicator;
+import org.springframework.boot.availability.ApplicationAvailability;
+import org.springframework.boot.availability.AvailabilityState;
+import org.springframework.boot.availability.ReadinessState;
+
+import java.util.Collection;
+
+public class CamelReadinessStateHealthIndicator extends 
ReadinessStateHealthIndicator {
+
+       private static final Logger LOG = 
LoggerFactory.getLogger(CamelReadinessStateHealthIndicator.class);
+
+       private CamelContext camelContext;
+
+       public CamelReadinessStateHealthIndicator(
+                       ApplicationAvailability availability,
+                       CamelContext camelContext) {
+               super(availability);
+
+               this.camelContext = camelContext;
+       }
+
+       @Override
+       protected AvailabilityState getState(ApplicationAvailability 
applicationAvailability) {
+               Collection<HealthCheck.Result> results = 
HealthCheckHelper.invokeReadiness(camelContext);
+
+               boolean isReady = checkState(results, LOG);
+
+               return isReady ?
+                               ReadinessState.ACCEPTING_TRAFFIC : 
ReadinessState.REFUSING_TRAFFIC;
+       }
+
+       public static boolean checkState(Collection<HealthCheck.Result> 
results, Logger log) {
+               boolean isUp = true;
+               for (HealthCheck.Result result : results) {
+                       if (!HealthCheck.State.UP.equals(result.getState())) {
+                               isUp = false;
+
+                               result.getError().ifPresent(error -> 
log.warn(result.getCheck().getId(), error));

Review Comment:
   Hmm do you want WARN logs every time this is invoked and there is some kind 
of error.
   
   I think either this need to be an option your can turn on|off



##########
core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/health/liveness/CamelLivenessStateHealthIndicator.java:
##########
@@ -0,0 +1,39 @@
+package org.apache.camel.spring.boot.actuate.health.liveness;

Review Comment:
   Add license header



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to