Kafka: Get broker host from ZooKeeper

前端 未结 5 1022
伪装坚强ぢ
伪装坚强ぢ 2020-12-02 13:32

For particular reasons I need to use both - ConsumerGroup (a.k.a. high-level consumer) and SimpleConsumer (a.k.a. low-level consumer) to read from

5条回答
  •  温柔的废话
    2020-12-02 14:19

    actually, there is ZkUtils from within Kafka (at least for 0.8.x line), that you can use with one small caveat: you'll need to re-implement ZkStringSerializer that would convert strings as UTF-8 encoded byte arrays. If you'd like to use Java8's streaming APIs, you can iterate over Scala collections throug scala.collection.JavaConversions. This is the thing that helped my case.

提交回复
热议问题