How to change start offset for topic?

后端 未结 4 1061
灰色年华
灰色年华 2020-12-04 12:46

It is possible to change the start offset for a new topic? I would like to create a new topic and start reading from the offset 10000. How?

4条回答
  •  甜味超标
    2020-12-04 13:29

    Since kafka 0.9 offsets are stored in a topic. To change offset, use the seek() method:

    public void seek(TopicPartition partition, long offset)
    

    Overrides the fetch offsets that the consumer will use on the next poll(timeout). If this API is invoked for the same partition more than once, the latest offset will be used on the next poll(). Note that you may lose data if this API is arbitrarily used in the middle of consumption, to reset the fetch offsets

提交回复
热议问题