Spring Boot 2.0.0.RC2 KafkaHealthIndicator,Actuator {“status”:“DOWN”}

时间:2018-02-24 17:43:36

标签: spring spring-boot apache-kafka spring-boot-actuator spring-kafka

我将我的应用程序从Spring Boot 2.0.0.M6移植到Spring 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的健康检查:

management.health.kafka.enabled=false

但我不喜欢它,我想解决它。

1 个答案:

答案 0 :(得分:0)

这对我来说很好......

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}

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