Spring Boot2.0.0.rc2Kafka健康指示器,执行器{“状态”:“关闭”}

zvms9eto  于 2021-06-07  发布在  Kafka
关注(0)|答案(1)|浏览(319)

我把我的应用程序从 Spring Boot 2.0.0.M6Spring Boot 2.0.0.RC2 遇到了这个问题 KafkaHealthIndicator 我现在认为我的Kafka身份是 DOWN .

kafka":{
     "status":"DOWN",
     "details":{
        "clusterId":"wpAKGc_DQBWy9YfPTLNctQ",
        "brokerId":"0",
        "nodes":1
     }
  }
``` `org.springframework.boot.actuate.kafka.KafkaHealthIndicator` 使用以下逻辑确定状态:

Status status = nodes >= replicationFactor ? Status.UP : Status.DOWN;

其中复制因子由以下属性检索: `transaction.state.log.replication.factor` 我已经添加了以下属性到我的Kafka `server.properties` :

offsets.topic.replication.factor=1
transaction.state.log.replication.factor=1
transaction.state.log.min.isr=1

但没用。
我做错了什么?如何解决?
现在,我使用时态解决方案来禁用kafka的healthcheck:

management.health.kafka.enabled=false

但我不喜欢它,我想修复它。
at0kjp5o

at0kjp5o1#

这对我来说很好。。。

transaction.state.log.replication.factor=1
transaction.state.log.min.isr=1

具有

@SpringBootApplication
public class So48965775Application {

    public static void main(String[] args) {
        SpringApplication.run(So48965775Application.class, args);
    }

    @Bean
    public ApplicationRunner runner(KafkaHealthIndicator health) {
        return args -> {
            Executors.newSingleThreadExecutor().execute(() -> {
                while (true) {
                    System.out.println(health.health());
                    try {
                        Thread.sleep(5000);
                    }
                    catch (InterruptedException e) {
                        Thread.currentThread().interrupt();
                    }
                }
            });
        };
    }

}

UP {clusterId=ZR4GdILXSFSIGI1wDiKNLg, brokerId=0, nodes=1}

更改属性后是否重新启动了代理?

相关问题