springboot 监听 Kafka集群只配置一个监听端口

Fantastic A 发表于: 2018-09-18   最后更新时间: 2018-09-18 17:14:17   6,276 游览

springboot上监听多个主题
screenshot
此主题在Broker2 上 Kafka集群是9094端口

screenshot
此主题在Broker0 上 Kafka集群是9092端口

screenshot
客户端配置只监听9092端口,上的这个主题。只能监听到一个端口上的主题吗?要配置所有集群端口才能监听到其他接点上的主题吗?

发表于 2018-09-18
添加评论

有发现机制,会发现所有的节点。

Fantastic A -> 半兽人 5年前

我这边 目前的情况 是只能监听到一个节点上的主题。也就是我 监听这个端口上的节点的主题  配置文件如下
  kafka:
    bootstrap-servers: 127.0.0.1:9092
    consumer:
      group-id: qy-001
      key-deserializer: org.apache.kafka.common.serialization.StringDeserializer
      value-deserializer: org.apache.kafka.common.serialization.StringDeserializer
      auto-offset-reset: latest
      enable-auto-commit: false
      auto-commit-interval: 1500
    template:
      default-topic: test-topic
    listener:
      concurrency: 5
    producer:
      batch-size: 1000
      key-serializer: org.apache.kafka.common.serialization.StringSerializer
      value-serializer: org.apache.kafka.common.serialization.StringSerializer

半兽人 -> Fantastic A 5年前

那2个broker是个一个集群中的吧?
已经生产和消费做测试了吗?

Fantastic A -> 半兽人 5年前

是一个集群的,只是监听时的主题全部都变成了单节点了。

半兽人 -> Fantastic A 5年前

先不用springboot,用生产和消费者命令来验证,是不是集群的。

Fantastic A -> 半兽人 5年前

命令创建的my-replicated-topic主题使用的集群

[root@localhost kafka_2.11-1.1.0]# bin/kafka-topics.sh --describe --zookeeper localhost:2181 --topic my-replicated-topic

OpenJDK 64-Bit Server VM warning: If the number of processors is expected to increase from one, then you should configure the number of parallel GC threads appropriately using -XX:ParallelGCThreads=N

Topic:my-replicated-topic PartitionCount:1 ReplicationFactor:3 Configs:

 Topic: my-replicated-topic Partition: 0 Leader: 0 Replicas: 0,1,2 Isr: 0,1,2



springboot创建的qy-001-YxRoomTransactionFile主题使用的单节点

[root@localhost kafka_2.11-1.1.0]# bin/kafka-topics.sh --describe --zookeeper localhost:2181 --topic qy-001-YxRoomTransactionFile

OpenJDK 64-Bit Server VM warning: If the number of processors is expected to increase from one, then you should configure the number of parallel GC threads appropriately using -XX:ParallelGCThreads=N

Topic:qy-001-YxRoomTransactionFile PartitionCount:1 ReplicationFactor:1 Configs:

 Topic: qy-001-YxRoomTransactionFile Partition: 0 Leader: 2 Replicas: 2 Isr: 2

Fantastic A -> 半兽人 5年前

嗯 将server.properties中的num.partitions数值调大,也就是调大默认创建主题的分区即可,谢谢@半兽人 啦

你的答案

查看kafka相关的其他问题或提一个您自己的问题