You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@kafka.apache.org by Liam Clarke-Hutchinson <li...@adscale.co.nz> on 2020/08/17 05:25:57 UTC

Quick clarification on ConsumerRecord.getOffset() and RecordMetadata.getOffset()

Kia ora koutou katoa,

Just double checking my understanding - the RecordMetadata returned by a
producer send returns an offset for the record - is it the actual offset of
the record on the partition, or the next offset? Reading the code indicates
it was the actual offset.

And likewise, when I call getOffset on a ConsumerRecord, if I'm reading the
comments in the code correctly, it was the offset of that record, not the
next offset.

As opposed to consumer.position which will return the next offset (and how
when offsets are committed, it's the next offset to read).

Am I correct in my understanding?

Kind regards,

Liam Clarke-Hutchinson

Re: Quick clarification on ConsumerRecord.getOffset() and RecordMetadata.getOffset()

Posted by Liam Clarke-Hutchinson <li...@adscale.co.nz>.
Brilliant, thanks for that Matthias :)

On Tue, 18 Aug. 2020, 3:07 am Matthias J. Sax, <mj...@apache.org> wrote:

> Your understanding is correct.
>
> On 8/16/20 10:25 PM, Liam Clarke-Hutchinson wrote:
> > Kia ora koutou katoa,
> >
> > Just double checking my understanding - the RecordMetadata returned by a
> > producer send returns an offset for the record - is it the actual offset
> of
> > the record on the partition, or the next offset? Reading the code
> indicates
> > it was the actual offset.
> >
> > And likewise, when I call getOffset on a ConsumerRecord, if I'm reading
> the
> > comments in the code correctly, it was the offset of that record, not the
> > next offset.
> >
> > As opposed to consumer.position which will return the next offset (and
> how
> > when offsets are committed, it's the next offset to read).
> >
> > Am I correct in my understanding?
> >
> > Kind regards,
> >
> > Liam Clarke-Hutchinson
> >
>
>

Re: Quick clarification on ConsumerRecord.getOffset() and RecordMetadata.getOffset()

Posted by "Matthias J. Sax" <mj...@apache.org>.
Your understanding is correct.

On 8/16/20 10:25 PM, Liam Clarke-Hutchinson wrote:
> Kia ora koutou katoa,
> 
> Just double checking my understanding - the RecordMetadata returned by a
> producer send returns an offset for the record - is it the actual offset of
> the record on the partition, or the next offset? Reading the code indicates
> it was the actual offset.
> 
> And likewise, when I call getOffset on a ConsumerRecord, if I'm reading the
> comments in the code correctly, it was the offset of that record, not the
> next offset.
> 
> As opposed to consumer.position which will return the next offset (and how
> when offsets are committed, it's the next offset to read).
> 
> Am I correct in my understanding?
> 
> Kind regards,
> 
> Liam Clarke-Hutchinson
>