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


##########
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:
   Well, you can configure 
`management.endpoint.health.group.liveness.show-details=always` but, it will 
only add information regarding the beans status, ex:
   
   ```
   {
      "status":"UP",
      "components":{
         "camelLivenessState":{
            "status":"UP"
         },
         "livenessState":{
            "status":"UP"
         }
      }
   }
   ```
   
   nothing really interesting for debug, anyway, kubernetes probes does not 
need it



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