Tie @KafkaListener health into Actuator Health
We have Spring Boot applications deployed to Kubernetes, using the /actuator/health/liveness and /actutator/health/readiness endpoints to control automatic pod restarts when the pods go unhealthy. When using the @KafkaListener attribute to create a Kafka Listener, we sometimes see a message trigger an OOM Error for running out of heap, shutting down the Kafka listener container. It would be a nice enhancement if failure detection was built into to Spring Boot and would cause the /actuator/health/liveness to go unhealthy to trigger a pod restart when this happens, either by default or opt-in.
The automated options today appear to be either using Application Events, https://docs.spring.io/spring-kafka/reference/kafka/events.html#idle-containers, or the KafkaListenerEndpointRegistry https://docs.spring.io/spring-kafka/reference/kafka/receiving-messages/kafkalistener-lifecycle.html.
Hi Spring Boot team,
Iām very interested in working on this enhancement.
My proposed approach for investigation:
Explore how to integrate KafkaListenerEndpointRegistry state into a custom or expanded KafkaHealthIndicator.
Ensure that the failure of a listener container (e.g., due to OOM or fatal exceptions) correctly propagates to the Actuator Health status.
Consider whether this should be a configurable property (opt-in) to avoid breaking existing deployment patterns.
I'd love to take this on if the team agrees during the triage/meeting. Please let me know if there are specific design constraints I should keep in mind.
Best regards, Mohammed Ghallab
Thanks for the enthusiasm, @MohammedGhallab, but there's nothing to work on at the moment. Please wait for issues to move out of waiting for triage state before offering to contribute.