From a330ca24c8a0502e8480bc0aae6179c4e325c724 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Sat, 30 Apr 2022 11:22:41 +0200 Subject: [PATCH] HealthIndicator implementiert: Implementierung selbst vergessen :/ --- .../kafka/ApplicationHealthIndicator.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/main/java/de/juplo/kafka/ApplicationHealthIndicator.java diff --git a/src/main/java/de/juplo/kafka/ApplicationHealthIndicator.java b/src/main/java/de/juplo/kafka/ApplicationHealthIndicator.java new file mode 100644 index 0000000..ab9782c --- /dev/null +++ b/src/main/java/de/juplo/kafka/ApplicationHealthIndicator.java @@ -0,0 +1,32 @@ +package de.juplo.kafka; + +import lombok.RequiredArgsConstructor; +import org.springframework.boot.actuate.health.Health; +import org.springframework.boot.actuate.health.HealthIndicator; +import org.springframework.stereotype.Component; + + +@Component +@RequiredArgsConstructor +public class ApplicationHealthIndicator implements HealthIndicator +{ + private final EndlessConsumer consumer; + + + @Override + public Health health() + { + try + { + return consumer + .exitStatus() + .map(Health::down) + .orElse(Health.outOfService()) + .build(); + } + catch (IllegalStateException e) + { + return Health.up().build(); + } + } +} -- 2.20.1