From a5cec9a25cb35fe4f69d4ccda7ca41be6d9e3fe5 Mon Sep 17 00:00:00 2001 From: Soby Chacko Date: Wed, 10 Oct 2018 17:25:19 -0400 Subject: [PATCH] Kafka Health Indicator changes Disable Kafka health indicator check if management.health.binders.enabled property is set to false. Currently, if this property is disabled, only the core spring-cloud-stream mechanism of collecting the health checks are disabled. The indivividual binders can still register the health check bean and boot health actuator will still pick it up. If the user turns off health check by disabling this property, then the stream app should completely disable any binder specific health check. Resolves #454 --- .../config/KafkaBinderHealthIndicatorConfiguration.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/spring-cloud-stream-binder-kafka/src/main/java/org/springframework/cloud/stream/binder/kafka/config/KafkaBinderHealthIndicatorConfiguration.java b/spring-cloud-stream-binder-kafka/src/main/java/org/springframework/cloud/stream/binder/kafka/config/KafkaBinderHealthIndicatorConfiguration.java index ef1cb9f55..93940b590 100644 --- a/spring-cloud-stream-binder-kafka/src/main/java/org/springframework/cloud/stream/binder/kafka/config/KafkaBinderHealthIndicatorConfiguration.java +++ b/spring-cloud-stream-binder-kafka/src/main/java/org/springframework/cloud/stream/binder/kafka/config/KafkaBinderHealthIndicatorConfiguration.java @@ -22,6 +22,7 @@ import java.util.Map; import org.apache.kafka.clients.consumer.ConsumerConfig; import org.apache.kafka.common.serialization.ByteArrayDeserializer; +import org.springframework.boot.actuate.autoconfigure.health.ConditionalOnEnabledHealthIndicator; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.cloud.stream.binder.kafka.KafkaBinderHealthIndicator; import org.springframework.cloud.stream.binder.kafka.KafkaMessageChannelBinder; @@ -40,11 +41,12 @@ import org.springframework.util.ObjectUtils; @Configuration @ConditionalOnClass(name="org.springframework.boot.actuate.health.HealthIndicator") +@ConditionalOnEnabledHealthIndicator("binders") class KafkaBinderHealthIndicatorConfiguration { @Bean - KafkaBinderHealthIndicator healthIndicator(KafkaMessageChannelBinder kafkaMessageChannelBinder, - KafkaBinderConfigurationProperties configurationProperties) { + KafkaBinderHealthIndicator kafkaBinderHealthIndicator(KafkaMessageChannelBinder kafkaMessageChannelBinder, + KafkaBinderConfigurationProperties configurationProperties) { Map props = new HashMap<>(); props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, ByteArrayDeserializer.class); props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, ByteArrayDeserializer.class);