Commands | Kafka Offsets

The Kafka client can query and set offsets for a given topic and partition. GetEarliestOffset(topic, partition) returns the oldest available offset, GetLatestOffset(topic, partition) returns the next offset to be written, and GetCommittedOffset(topic, partition) returns the last offset committed by the consumer group. All three return an Int64.

Use CommitOffset(topic, partition, offset) to commit a specific offset for the consumer group, so that consumption resumes from that position on the next session.

Basic Usage


var
  vEarliest, vLatest, vCommitted: Int64;
begin
  vEarliest := oKafka.GetEarliestOffset('my-topic', 0);
  vLatest := oKafka.GetLatestOffset('my-topic', 0);
  vCommitted := oKafka.GetCommittedOffset('my-topic', 0);

  // commit a specific offset for the consumer group
  oKafka.CommitOffset('my-topic', 0, vLatest);
end;