最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

java - Kafka partition not getting assigned when application run locally - Stack Overflow

programmeradmin0浏览0评论

I am running kafka as container, here is the part of compose file

kafka:
    image: bitnami/kafka:latest
    container_name: kafka
    restart: always
    deploy:
      resources:
        limits:
          memory: 1024M
    ports:
      - '9092:9092'
    volumes:
      - "kafka_data_storage:/bitnami"
    environment:
      KAFKA_CFG_NODE_ID: 0
      KAFKA_CFG_PROCESS_ROLES: controller,broker
      ALLOW_PLAINTEXT_LISTENER: "yes"
      KAFKA_CFG_LISTENERS: INTERNAL://:19092,CONTROLLER://:9093,EXTERNAL://:9092
      KAFKA_CFG_ADVERTISED_LISTENERS: INTERNAL://kafka:19092,EXTERNAL://localhost:9092
      KAFKA_CFG_INTER_BROKER_LISTENER_NAME: INTERNAL
      KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP: INTERNAL:PLAINTEXT,CONTROLLER:PLAINTEXT,EXTERNAL:PLAINTEXT
      KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE: "false"
      KAFKA_CFG_CONTROLLER_QUORUM_VOTERS: 0@kafka:9093
      KAFKA_CFG_CONTROLLER_LISTENER_NAMES: CONTROLLER
    healthcheck:
      test: [ "CMD", "kafka-topics.sh", "--list", "--bootstrap-server", "localhost:9092" ]
      interval: 10s
      timeout: 10s
      retries: 5

I have a java service using spring kafka that is consuming from one of the topic in this cluster and I have verified the topic is present when I start the service. Here is the service applicaton.yaml config for kafka:

kafka:
    bootstrap-servers:
      - localhost:9092
    producer:
      client-id: some-client-id
      key-serializer: org.apache.kafkamon.serialization.StringSerializer
      value-serializer: org.apache.kafkamon.serialization.StringSerializer
    consumer:
      group-id: some-client-id
      auto-offset-reset: earliest
      key-deserializer: org.apache.kafkamon.serialization.StringDeserializer
      value-deserializer: org.apache.kafkamon.serialization.StringDeserializer

It used to work as expected and I used to see this log at the very end on startup:

INFO 1 --- [ntainer#0-0-C-1] o.s.k.l.KafkaMessageListenerContainer    : some-client-id: partitions assigned: [some-topic-0]

But from past two days it is acting out and I see the following log at end of startup and it keeps on repeating:

INFO 45520 --- [ntainer#0-0-C-1] org.apache.kafka.clients.NetworkClient   : [Consumer clientId=consumer-some-client-1, groupId=some-client] Disconnecting from node -1 due to request timeout.
INFO 45520 --- [ntainer#0-0-C-1] org.apache.kafka.clients.NetworkClient   : [Consumer clientId=consumer-some-client-1, groupId=some-client] Cancelled in-flight API_VERSIONS request with correlation id 8 due to node -1 being disconnected (elapsed time since creation: 32563ms, elapsed time since send: 32563ms, request timeout: 30000ms)
WARN 45520 --- [ntainer#0-0-C-1] org.apache.kafka.clients.NetworkClient   : [Consumer clientId=consumer-some-client-1, groupId=some-client] Bootstrap broker localhost:9092 (id: -1 rack: null) disconnected

This has completely blocked my work, there are other services as well which are not able to connect to kafka. I have tried:

  • cleaning and running compose
  • deleting images and pulling them back and starting compose
  • downgrading kafka version
  • restart PC

None has worked. When I run any service as a container in the same compose, it is able to connect to kafka but locally it does not.

I would like to know why log says the id of node is -1?

发布评论

评论列表(0)

  1. 暂无评论