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


##########
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:
   I can lower the log level to debug, I think it makes sense to log the error 
since by default the readiness/liveness probe shows only UP or DOWN without 
further information.
   
   Anyway I'll add an option CamelHealthCheckConfigurationProperties to 
enable/disable the log



-- 
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