spring-boot icon indicating copy to clipboard operation
spring-boot copied to clipboard

Tie @KafkaListener health into Actuator Health

Open scottbusche-usps opened this issue 7 months ago • 2 comments

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.

scottbusche-usps avatar Apr 06 '26 20:04 scottbusche-usps

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

MohammedGhallab avatar Apr 12 '26 17:04 MohammedGhallab

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.

wilkinsona avatar Apr 13 '26 06:04 wilkinsona