【问题标题】:Spring Cloud Stream Kafka won't connectSpring Cloud Stream Kafka 无法连接
【发布时间】:2020-08-22 02:36:37
【问题描述】:

我正在使用这个 docker compose:

version: '2'
services:

  zookeeper:
    image: confluentinc/cp-zookeeper:4.1.1
    hostname: zookeeper
    ports:
    - "32181:32181"
    environment:
      ZOOKEEPER_CLIENT_PORT: 32181
      ZOOKEEPER_TICK_TIME: 2000
      ZOOKEEPER_SYNC_LIMIT: 2

  kafka:
    image: confluentinc/cp-kafka:4.1.1
    hostname: kafka
    ports:
    - "29092:29092"
    depends_on:
    - zookeeper
    environment:
      KAFKA_BROKER_ID: 1
      KAFKA_ZOOKEEPER_CONNECT: zookeeper:32181
      KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:29092
      KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1

我的属性是:

spring.cloud.stream.bindings.event.binder=event-binder
spring.cloud.stream.bindings.event.destination=event    

spring.cloud.stream.binders.event-binder.type=kafka

spring.cloud.stream.kafka.binder.brokers=localhost:29092
spring.cloud.stream.kafka.binder.zkNodes=localhost:32181

但我收到此错误:

9:54:14.534 [main] INFO  o.a.kafka.common.utils.AppInfoParser - Kafka version : 2.0.1
19:54:14.534 [main] INFO  o.a.kafka.common.utils.AppInfoParser - Kafka commitId : fa14705e51bd2ce5
19:54:14.576 [kafka-admin-client-thread | adminclient-1] WARN  o.apache.kafka.clients.NetworkClient - [AdminClient clientId=adminclient-1] Connection to node -1 could not be established. Broker may not be available.
19:54:14.679 [kafka-admin-client-thread | adminclient-1] WARN  o.apache.kafka.clients.NetworkClient - [AdminClient clientId=adminclient-1] Connection to node -1 could not be established. Broker may not be available.
19:

我的 Spring Boot 版本是 2.1.4.RELEASE,我的 Spring Cloud 版本是 Greenwich.SR1。

提前致谢!

【问题讨论】:

    标签: docker apache-kafka spring-cloud-stream spring-cloud-stream-binder-kafka


    【解决方案1】:

    有了这个配置,我觉得你需要

    KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:29092

    【讨论】:

      【解决方案2】:

      你应该配置:

      spring.cloud.stream.kafka.binder.brokers=PLAINTEXT://你的主机:29092 spring.cloud.stream.kafka.binder.zkNodes=PLAINTEXT://你的主机:29092

      在文件 docker-compose.yml 你应该有: KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://你的主机:29092 如果在 docker 中连接成功,并且在 spring cloud stream 中运行成功。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2018-04-28
        • 2018-08-29
        • 1970-01-01
        • 2017-11-24
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多