Spring Boot 如何从Kafkaesque工具连接到docker Kafka容器?

l7wslrjt  于 2023-04-30  发布在  Spring
关注(0)|答案(1)|浏览(141)

我试图能够玩一些主题在我的本地机器上。
我想使用Kafkaesque https://kafka.esque.at/
我的Sping Boot 应用程序有以下配置:
我发现了一个docker映像,我添加到Bitnami的docker-compose文件中,它看起来像这样用于设置环境

zookeeper:
    image: docker.io/bitnami/zookeeper:3.8
    ports:
      - "2181:2181"
    volumes:
      - "zookeeper_data:/bitnami"
    environment:
      - ALLOW_ANONYMOUS_LOGIN=yes
  kafka:
    image: docker.io/bitnami/kafka:3.4
    ports:
      - "9092:9092"
      - "9000:9000"
      - "9080:8080"
      - "9081:9081"
      - "9082-9084:9082-9084"
    volumes:
      - "kafka_data:/bitnami"
    environment:
      - ALLOW_PLAINTEXT_LISTENER=yes
      - KAFKA_ENABLE_KRAFT=no
      - KAFKA_CFG_ZOOKEEPER_CONNECT=zookeeper:2181
      - KAFKA_CFG_LISTENERS=PLAINTEXT://:9092
    depends_on:
      - zookeeper
  schema-registry:
    image: docker.io/bitnami/schema-registry:7.3
    ports:
      - '8081:8081'
    depends_on:
      - kafka
    environment:
      - SCHEMA_REGISTRY_LISTENERS=http://0.0.0.0:8081
      - SCHEMA_REGISTRY_KAFKA_BROKERS=PLAINTEXT://kafka:9092

在我的本地应用程序属性中,我这样设置配置

spring.kafka:
  bootstrap-servers: localhost:9092
  properties:
    schema.registry.url: http://localhost:8081
  streams:
    cleanup.on-startup: true

在kafkaesque(https://kafka.esque.at/)中,我这样设置属性

我的案例是在这里的场景4中展示的https://www.confluent.io/blog/kafka-client-cannot-connect-to-broker-on-aws-on-docker-etc/

kgsdhlau

kgsdhlau1#

我想你应该看看如何在代理之后或在Docker容器中连接到Kafka。最有可能的问题是,分配给容器的IP地址类似于10。x.y.z,当你连接到127。0.0.1.这将破坏客户端(Kafkesque)和服务器(Kafka)之间的Kafka协议。这里是足够好的解释在这个article
作为替代方案,您可以寻找如何将kafkaesque放入docker容器中。这并不简单,因为GUI应用程序在Docker容器中没有得到很好的支持。

相关问题