无法将Spring应用程序连接到Debezium Kafka

时间:2019-09-20 13:47:33

标签: apache-kafka apache-zookeeper spring-kafka debezium

我试图将我的spring应用程序连接到debezium / kafka:0.10,但是没有成功。最初,该应用程序使用wurstmeister / kafka图像,但是现在,我要为debezium引入一项新功能,并且希望仅对其中一个使用kafka图像。我无法将两个应用程序都连接到debezium kafka或将debezium连接到wurstmeister kafka。有人知道这两种图像只能使用一张吗?任何想法都欢迎:)

问题是该应用无法将主题创建到debezium容器中。而且debezium无法使用wurstmeister kafka图像。

ERROR 18864 --- [           main] o.springframework.kafka.core.KafkaAdmin  : Could not configure topics

org.springframework.kafka.KafkaException: Timed out waiting to get existing topics; nested exception is java.util.concurrent.TimeoutException
    at org.springframework.kafka.core.KafkaAdmin.lambda$checkPartitions$2(KafkaAdmin.java:235) ~[spring-kafka-2.2.3.RELEASE.jar:2.2.3.RELEASE]
    at java.base/java.util.HashMap.forEach(HashMap.java:1336) ~[na:na]
services:
  zookeeper:
    image: debezium/zookeeper:0.10
    ports:
      - 2181:2181
      - 2888:2888
      - 3888:3888
  kafka:
    image: debezium/kafka:0.10
    ports:
      - 9092:9092
    links:
      - zookeeper
    environment:
      - ZOOKEEPER_CONNECT=zookeeper:2181
      - ADVERTISED_HOST_NAME=10.0.75.1
  connect:
    image: debezium/connect:0.10
    ports:
      - 8083:8083
    links:
      - kafka
      - mysql
    environment:
      - BOOTSTRAP_SERVERS=kafka:9092
      - GROUP_ID=1
      - CONFIG_STORAGE_TOPIC=my_connect_configs
      - OFFSET_STORAGE_TOPIC=my_connect_offsets
      - STATUS_STORAGE_TOPIC=my_connect_statuses

1 个答案:

答案 0 :(得分:0)

ADVERTISED_HOST_NAME 一起,您需要向容器环境中添加 ADVERTISED_LISTENERS

ADVERTISED_LISTENERS-经纪人将在Zookeeper中注册此值,并且当外部世界想要连接到您的Kafka群集时,他们可以通过您在ADVERTISED_LISTENERS属性中提供的网络进行连接。

示例:

import speech_recognition as sr

rec = sr.Recognizer()

print('say something')
with sr.Microphone() as source:
    audio = rec.listen(source)
    voice_data = rec.recognize_google(audio)

print(voice_data)