Skip to content

Consumer Group (Classic Protocol)

A consumer group lets multiple consumers cooperatively consume a topic: each partition is consumed by only one member at a time, and membership changes trigger an automatic rebalance. This page covers the classic protocol — the full path built on JoinGroup / SyncGroup / Heartbeat. For the next-generation KIP-848 protocol see Next-Gen Consumer Group.

Coordinator

The group coordinator is the current meta-service Raft leader. A client first locates it with FindCoordinator, then sends subsequent requests there. A request that reaches a non-coordinator node returns NOT_COORDINATOR so the client redirects.

Full Path

RobustMQ Kafka classic consumer group

StepAPINotes
1. Locate coordinatorFindCoordinatorFind the coordinator node for the group
2. First joinJoinGroupThe first call carries no member id; the coordinator returns MEMBER_ID_REQUIRED and assigns one
3. RejoinJoinGroupRejoin with the member id; the coordinator picks one member as leader and sends it the member list
4. Sync assignmentSyncGroupThe client leader computes the partition assignment and uploads it; the broker only relays each member's assignment back
5. Maintain membershipHeartbeatPeriodic keepalive; when the coordinator starts a rebalance it returns REBALANCE_IN_PROGRESS to prompt a rejoin
6. LeaveLeaveGroupVoluntarily leave, triggering a rebalance

Key design: the client leader computes the assignment; the broker only relays it. The assignor (range, roundrobin, etc.) is decided entirely on the client — the broker does no computation.

Offset Commit and Resumed Reads

During consumption, a member commits offsets via OffsetCommit (commitSync commits synchronously and waits for the ack). Offsets are persisted in the meta layer, so:

  • When a new member takes over a partition, it resumes from that partition's committed offset — no re-reads, no gaps (falling back to auto.offset.reset when no offset exists).
  • Offset lookup, reset, and lag computation are covered in Offset Management.

Rebalance

A change in the member set triggers a rebalance, re-splitting partitions across the new members:

CaseResult
Two consumers subscribe to the same topicPartitions split between them (e.g. half each)
A member leavesIts partitions are reassigned to the remaining members
A new member joinsThe generation increments and partitions are reassigned

During a rebalance, the coordinator returns REBALANCE_IN_PROGRESS on heartbeats; members re-run JoinGroupSyncGroup to complete a new assignment.

🎉 既然都登录了 GitHub,不如顺手给我们点个 Star 吧!⭐ 你的支持是我们最大的动力 🚀