天天看點

[Kafka基礎]-- auto.offset.reset介紹

我們先看看最新的官方文檔說明:

What to do when there is no initial offset in Kafka or if the current offset does not exist any more on the server (e.g. because that data has been deleted):

  • earliest: automatically reset the offset to the earliest offset
  • latest: automatically reset the offset to the latest offset
  • none: throw exception to the consumer if no previous offset is found for the consumer's group
  • anything else: throw exception to the consumer.

翻譯:

當Kafka中沒有初始偏移或如果目前偏移在伺服器上不再存在時(例如,因為該資料已被删除),該怎麼辦:

  1. 最早:自動将偏移重置為最早的偏移
  2. 最新:自動将偏移重置為最新偏移
  3. none:如果沒有為消費者組找到以前的偏移,則向消費者抛出異常
  4. 任何其他:抛出異常到消費者。

“auto.offset.reset”的值隻能是:[latest, earliest, none]中的一個,預設是"latest"