How do I use multiple consumers in Kafka?

后端 未结 3 898
再見小時候
再見小時候 2021-01-31 16:21

I am a new student studying Kafka and I\'ve run into some fundamental issues with understanding multiple consumers that articles, documentations, etc. have not been too helpful

3条回答
  •  执笔经年
    2021-01-31 16:58

    I think your problem lies with the auto.offset.reset property. When a new consumer reads from a partition and there's no previous committed offset, the auto.offset.reset property is used to decide what the starting offset should be. If you set it to "largest" (the default) you start reading at the latest (last) message. If you set it to "smallest" you get the first available message.

    So add:

    properties.put("auto.offset.reset", "smallest");
    

    and try again.

    * edit *

    "smallest" and "largest" were deprecated a while back. You should use "earliest" or "latest" now. Any questions, check the docs

提交回复
热议问题