【发布时间】:2020-01-20 06:27:28
【问题描述】:
我有一个使用 apache kafka-streams 的 Spring Boot 应用程序。我不使用弹簧云流。我添加了执行器健康检查端点。我在application.yml 中这样配置它:
management:
health.db.enabled: false
endpoints.web:
base-path:
path-mapping.health: /
当引发运行时异常并且我的流已停止,如日志所示,但运行状况检查状态为 UP。
2019-09-17 13:16:31.522 INFO 1 --- [ Thread-5] org.apache.kafka.streams.KafkaStreams : stream-client [lpp-model-stream-7e6e8fea-fcad-4033-92a4-5ede50de6e17] Streams client stopped completely
如何将 kafka 流状态绑定到健康检查端点?
我的 pom.xml:
<dependencies>
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-streams</artifactId>
</dependency>
<dependency>
<groupId>data-wizards</groupId>
<artifactId>lpp-common-avro</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>io.confluent</groupId>
<artifactId>kafka-streams-avro-serde</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<dependency>
<groupId>io.vavr</groupId>
<artifactId>vavr</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
链接到我创建流的代码:https://gist.github.com/solveretur/fc4fdd6c7663dc4d58fe72d48029f9c3
【问题讨论】:
-
您是否尝试过实现自定义 HealthIndicator?,您可以覆盖使用 KafkaStreams.setExceptionHandler 来标记自定义 HealthIndicator 实现中的错误。
-
这正是我想要做的 - 实现一个 HealthIndicator - 但是我在 Java / Spring / Kafka 方面不够精通,我想找到一些工作示例将其复制到我的项目
-
我根据以下理解回答了这个问题。如果这不起作用,您能否提供一个可以处理的minimal reproducible 示例?
标签: spring spring-boot apache-kafka