1
votes

First time working with Kafka and Docker-compose. I'm trying to publish a message to Kafka but I get an error (look below). What is the issue?

2020-07-21 16:37:40,274 WARN [kafka-producer-network-thread | producer-1] org.apache.kafka.clients.NetworkClient$DefaultMetadataUpdater: [Producer clientId=producer-1] 1 partitions have leader brokers without a matching listener, including [demo-topic-0]

Here is my 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
1

1 Answers

2
votes

My question was partially answered here Leader brokers without a matching listener error in kafka.

docker-compose rm -sfv

The above code ultimately resolved the issue of multiple consumers.