Rahul Vedpathak
Rahul Vedpathak

Reputation: 1436

What happens if offset specified by kafka consumer is not present in Broker?

I am new to kafka. I want to understand how kafka consumer behaves when offset specified by it is not present. Maybe the message at the given offset is deleted due to retention policy or consumer specified an invalid offset value.

Upvotes: 6

Views: 4232

Answers (2)

suresiva
suresiva

Reputation: 3173

It depends on the auto.offset.reset's mode that you have configured. Please find below about what will happen with each mode when you seek to an offset that doesn't exist in the given topic's partition.

auto.offset.reset=earliest

  • Partition's offset will be reset to 0 and all messages will be consumed enter image description here

auto.offset.reset=latest

  • Partition's offset will be reset to the last known offset and will be consuming only the new messages enter image description here

auto.offset.reset=none

Upvotes: 5

Simon Clark
Simon Clark

Reputation: 654

Your consumer will use your auto.offset.reset setting to reset its offset to a valid position. If no reset option has been specified, then the Broker will throw an InvalidOffsetException.

Upvotes: 5

Related Questions