【问题标题】:Stop Consumer when is disconnected (Spring Boot + Kafka)断开连接时停止消费者(Spring Boot + Kafka)
【发布时间】:2021-08-16 22:47:16
【问题描述】:

我需要帮助一位使用 Spring Boot 的消费者。我需要在断开连接时停止应用程序,例如 10 分钟。什么时候断开

2021-08-16 18:39:21.927  WARN 15548 --- [ntainer#0-0-C-1] o.a.k.c.NetworkClient                    : [Consumer clientId=topicTest, groupId=goupTest-] Connection to node 1 (localhost/127.0.0.1:9092) could not be established. Broker may not be available.
2021-08-16 18:39:24.942  WARN 15548 --- [ntainer#0-0-C-1] o.a.k.c.NetworkClient                    : [Consumer clientId=topicTest, groupId=goupTest] Connection to node 1 (localhost/127.0.0.1:9092) could not be established. Broker may not be available.
2021-08-16 18:39:24.943  INFO 15548 --- [ntainer#0-0-C-1] o.a.k.c.FetchSessionHandler              : [Consumer clientId=topicTest, groupId=goupTest] Error sending fetch request (sessionId=1591961485, epoch=INITIAL) to node 1:

org.apache.kafka.common.errors.DisconnectException: null

或无法连接时

2021-08-16 18:42:15.960  WARN 23068 --- [ntainer#0-0-C-1] o.a.k.c.NetworkClient                    : [Consumer clientId=topicTest, groupId=goupTest] Connection to node -1 (localhost/127.0.0.1:9092) could not be established. Broker may not be available.
2021-08-16 18:42:15.961  WARN 23068 --- [ntainer#0-0-C-1] o.a.k.c.NetworkClient                    : [Consumer clientId=topicTest, groupId=goupTest] Bootstrap broker localhost:9092 (id: -1 rack: null) disconnected
2021-08-16 18:42:19.125  WARN 23068 --- [ntainer#0-0-C-1] o.a.k.c.NetworkClient                    : [Consumer clientId=topicTest, groupId=goupTest] Connection to node -1 (localhost/127.0.0.1:9092) could not be established. Broker may not be available.
2021-08-16 18:42:19.126  WARN 23068 --- [ntainer#0-0-C-1] o.a.k.c.NetworkClient                    : [Consumer clientId=topicTest, groupId=goupTest] Bootstrap broker localhost:9092 (id: -1 rack: null) disconnected

我将 ConsumerFactory 和 ConcurrentKafkaListenerContainerFactory 用于我的消费者的所有配置

【问题讨论】:

    标签: spring spring-boot apache-kafka consumer


    【解决方案1】:

    Kafka客户端将自动重试以从断开连接中恢复,您应该会看到更多日志,您也可以将日志级别更改为debug以查看更多详细信息。

    还可以查看这张票,了解未来有关此问题的更多更新:https://issues.apache.org/jira/browse/KAFKA-6520。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-04-02
      • 1970-01-01
      • 2017-09-23
      • 2022-12-24
      • 2016-12-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多