I'm currently, investigating the case of the original HealthIndicator for Kafka being removed for various reasons. I also came across the current existing spring-cloud Kafka HealthIndicator

Wouldn't it also make sense to port the existing spring-cloud HealthIndicator to spring-boot? In that case, many people wouldn't need to worry about implementing it themselves because it can be tricky.

Another nice fact would be that people wouldn't need to worry about upgrading to different versions when they implemented where they might use various mechanisms that could get removed in the future.

In my specific case, I'm using the ReactiveKafkaConsumerTemplate and I want to have a check that would set the application health state to DOWN when the consumer behind it dies. I also checked the possibilities of using Flux#doFinally etc. but a real HealthIndicator which checks that automatically would be a greater solution.

Also for the non-reactive users, it would help a lot to have something that checks e.g. the listener's state if its consumer is still alive. Like it is in the spring-cloud HealthIndicator

Comment From: wilkinsona

Thanks for the suggestion.

Unfortunately, I don't see how the health indicator from Spring Cloud Stream's Kafka binder can be ported to Spring Boot. The Kafka binder has a lot more information available to it about how Kafka's being used than a general Spring Boot app does. This information allows it to identify what it should check to determine whether or not Kafka's healthy for its purposes. Spring Boot doesn't have this information available and has to fall back on a more general-purpose approach.

It sounds like you have already seen https://github.com/spring-projects/spring-boot/issues/14088 which describes why it isn't possible to offer a general-purpose health indicator for Kafka. I don't think anything's changed since then and it makes sense for Spring Cloud Stream's Kafka Binder to continue to provide its own indicator.

Comment From: original-codematrix

Thanks for the fast reply!

Yes, I already investigated #14088 sadly I thought it may not be possible even with the given example in the spring-cloud project. I thought it helped but I "tried" to reimplement that behavior and found out as you mentioned that the information I have is much less compared to the spring-cloud way 😄

I saw that the spring-cloud implementation got a KafkaTopicProvisioner which provides a ton of information for the check. So I understand the fact that it isn't easy to provide an out-of-the-box working check for everyone.

My hopes were high that somehow having a port without the need to implement it on my own with the risk of problems when I need to upgrade to newer versions 😄

Comment From: wilkinsona

Unfortunately, I think you'll have to implement your own, tailored to how your application's using Kafka.