kafka producer error“1个分区具有没有匹配侦听器的引导代理”

z8dt9xmd  于 2021-06-04  发布在  Kafka
关注(0)|答案(1)|浏览(332)

第一次与Kafka和docker合作。我正试图向Kafka发布一条消息,但出现了一个错误(请看下面)。问题是什么?
2020-07-21 16:37:40274警告[kafka producer network thread | producer-1]org.apache.kafka.clients.networkclient$defaultmetadataupdater:[producer-clientid=producer-1]1分区具有没有匹配侦听器的leader代理,包括[demo-topic-0]
这是我的docker-compose.yml:

version: '3'

services:
  zookeeper:
    image: wurstmeister/zookeeper
    ports:
      - "2181:2181"
  kafka:
    image: wurstmeister/kafka
    links:
      - zookeeper:zk
    ports:
      - "9092:9092"
    expose:
      - "9093"
    environment:
      KAFKA_ZOOKEEPER_CONNECT: zk:2181
      KAFKA_MESSAGE_MAX_BYTES: 2000000
      KAFKA_CREATE_TOPICS: "demo-topic:1:1"
      KAFKA_BROKER_ID: 1
      KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9093,PLAINTEXT_HOST://localhost:9092
      KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
      KAFKA_LISTENERS: PLAINTEXT://kafka:9093,PLAINTEXT_HOST://localhost:9092
      KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
      KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    depends_on:
      - zookeeper

  player-service-ci:
    image: player/player-service:latest
    container_name: player-service-ci
    restart: unless-stopped
    volumes:
      - /tmp/app/logs:/logs
    environment:
      - "JAVA_OPTS=-Xmx256m -Xms128m"
      - "spring.profiles.active=ci"
      - "LOGS_FILENAME=player-service-logger-ci"
      - "SPRING_KAFKA_BOOTSTRAPSERVERS=kafka:9093"
    ports:
      - 17500:17500

networks:
  default:
    external:
      name: ci
o75abkj4

o75abkj41#

我的问题在这里得到了部分回答,但在Kafka中没有出现匹配的侦听器错误。

docker-compose rm -sfv

上面的代码最终解决了多个消费者的问题。

相关问题