现象描述:

代码连接本地kafka没有问题 能监听到监听的topic,可获取通道中的所有topic

将kafka放到服务器上,本地程序启动报异常,可获取kafka中所有的topic,但是监听topic不起作用

启动时,报下面两个异常

Bootstrap broker localhost:9092 (id: -1 rack: null) disconnected

Connection to node -1 (localhost/127.0.0.1:9092) could not be established. Broker may not be available.

解决方案:

kafka:
    TOPIC: 002
    #kafka历史队列
    TOPICH: 102
    producer:
      bootstrap-servers: IP:端口
      key-serializer: org.apache.kafka.common.serialization.IntegerSerializer
      value-serializer: org.apache.kafka.common.serialization.StringSerializer
      retries: 10
      acks: all
      linger.ms: 1
      batch.size: 16384
      buffer.memory: 33554432
    consumer:
      group-id: consumer-group
      auto-commit-interval: 1S
      auto-offset-reset: earliest
      enable-auto-commit: true
      key-deserializer: org.apache.kafka.common.serialization.StringDeserializer
      value-deserializer: org.apache.kafka.common.serialization.StringDeserializer

在kafka 下面添加

kafka:
  bootstrap-servers: IP:端口,IP:端口,IP:端口

问题解决

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐