DE Mastery GitHub

Build your own mini Kafka · Stage 7 of 8

Consumer-group offsets (OffsetCommit / OffsetFetch)

Let consumers checkpoint their progress.

  • FindCoordinator (api 10): you are your own group coordinator.
  • OffsetCommit (api 8): store an offset per (group, topic, partition).
  • OffsetFetch (api 9): read it back; return −1 when there is no commit.

Mind the request shapes: OffsetFetch v8+ uses a groups array and v9 adds member_id + member_epoch before the topics.

Tests: commit then fetch in the same group (fresh consumer); unknown group has no offset; two groups keep independent offsets.

Hints

Hint 1

FindCoordinator (api 10) must point the client at this broker (it is its own group coordinator). Then OffsetCommit (api 8) stores an offset for (group, topic, partition) and OffsetFetch (api 9) reads it back.

Hint 2

Key your committed offsets by (group, topic, partition). An OffsetFetch for a group/partition with no commit must return -1 (no committed offset).

Hint 3

OffsetFetch v8+ uses a 'groups' array; v9 adds member_id + member_epoch in the request before the topics. Parse those or your topic array will be misaligned. Persist the offsets so a fresh consumer in the same group reads them.

Run it locally
uv run de start KFK-BYO/07-consumer-group-offsets
uv run de test