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


##########
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:
   @davsclaus in case of a disconnected kafka consumer, the error is logged 
only when http://localhost:8080/actuator/health/readiness or 
http://localhost:8080/actuator/health/ are invoked, but the console is full of 
warns from kafka, do you think it is worth to have a flag to enable/disable the 
warn for the probes?



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