diff --git a/src/main/java/com/deviceinsight/kafka/health/KafkaHealthAutoConfiguration.java b/src/main/java/com/deviceinsight/kafka/health/KafkaHealthAutoConfiguration.java new file mode 100644 index 0000000..ff590fa --- /dev/null +++ b/src/main/java/com/deviceinsight/kafka/health/KafkaHealthAutoConfiguration.java @@ -0,0 +1,30 @@ +package com.deviceinsight.kafka.health; + +import org.springframework.boot.actuate.health.AbstractHealthIndicator; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.kafka.KafkaProperties; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +@ConditionalOnClass(AbstractHealthIndicator.class) +public class KafkaHealthAutoConfiguration { + + @Bean + @ConditionalOnMissingBean(KafkaHealthProperties.class) + @ConfigurationProperties("kafka.health") + public KafkaHealthProperties kafkaHealthProperties() { + return new KafkaHealthProperties(); + } + + @Bean + @ConditionalOnMissingBean(KafkaConsumingHealthIndicator.class) + public KafkaConsumingHealthIndicator kafkaConsumingHealthIndicator(KafkaHealthProperties kafkaHealthProperties, + KafkaProperties processingProperties) { + return new KafkaConsumingHealthIndicator(kafkaHealthProperties, processingProperties.buildConsumerProperties(), + processingProperties.buildProducerProperties()); + } + +} diff --git a/src/main/resources/META-INF/spring.factories b/src/main/resources/META-INF/spring.factories new file mode 100644 index 0000000..e50bdc6 --- /dev/null +++ b/src/main/resources/META-INF/spring.factories @@ -0,0 +1 @@ +org.springframework.boot.autoconfigure.EnableAutoConfiguration=com.deviceinsight.kafka.health.KafkaHealthAutoConfiguration \ No newline at end of file