When a Kafka consumer switches to group.protocol=consumer, which settings move to the broker and which client configs stop working?
answer
- three things the broker now owns
- group.consumer.* on the broker
- naming an assignor, not shipping one
- ConfigException at construction
- regex evaluated on the broker
basics
~10 sUnder group.protocol=consumer the broker owns assignment, heartbeat interval and session timeout. Setting partition.assignment.strategy, heartbeat.interval.ms or session.timeout.ms on the client throws a ConfigException at construction, and enforceRebalance() only logs a warning.
solid answer
~40 sWith `group.protocol=consumer` the broker's group coordinator takes over three things the classic client controlled. The heartbeat interval is `group.consumer.heartbeat.interval.ms` (default 5000 ms) and is returned in every `ConsumerGroupHeartbeat` response; the session timeout is `group.consumer.session.timeout.ms` (default 45000 ms); and assignment runs on the broker with the assignors listed in `group.consumer.assignors` (`uniform`, `range`, first one is the default). The client may only name one of them with `group.remote.assignor`. If `partition.assignment.strategy`, `heartbeat.interval.ms` or `session.timeout.ms` is set, the `KafkaConsumer` constructor fails with a `ConfigException`, and `enforceRebalance()` becomes a no-op that logs a warning. `max.poll.interval.ms` still applies as the rebalance timeout, and `subscribe(SubscriptionPattern)` lets the broker evaluate an RE2J topic regex.
code
properties · 11 linesbootstrap.servers=broker1:9092
group.id=orders-service
group.protocol=consumer
# optional: name a server-side assignor; omit to use the broker's first group.consumer.assignors entry
group.remote.assignor=range
# still a client setting: becomes the rebalance timeout
max.poll.interval.ms=300000
# must be removed under group.protocol=consumer, or the KafkaConsumer constructor throws ConfigException:
# partition.assignment.strategy=org.apache.kafka.clients.consumer.RangeAssignor
# session.timeout.ms=45000
# heartbeat.interval.ms=3000go deeper
Remember three moves to the broker: assignment, heartbeat interval and session timeout. The client only names an assignor with group.remote.assignor.
Know the exact failure: setting partition.assignment.strategy, heartbeat.interval.ms or session.timeout.ms under group.protocol=consumer makes the KafkaConsumer constructor throw ConfigException, while enforceRebalance() just logs a warning.
Explain what still belongs to the client, max.poll.interval.ms as the rebalance timeout, and how per-group configs override broker defaults within min/max bounds when one group needs different liveness.
Weigh centralisation: one broker setting now decides failure detection for every group, so define who owns those values and how teams request per-group overrides.
## The shift: from client-chosen to broker-chosen Under the classic protocol each `KafkaConsumer` decides how its group behaves: its `partition.assignment.strategy` decides how partitions are split, and its `heartbeat.interval.ms` and `session.timeout.ms` decide how quickly it is declared dead. Kafka 4.0's consumer group protocol (KIP-848), enabled per client with `group.protocol=consumer`, moves all three decisions to the broker's **group coordinator**. The client keeps the things only it can know (its subscription, its rack, how long it may take to finish a batch) and receives the rest. ## What the broker now owns | Concern | Broker config | Default (Kafka 4.3.1 source) | |---|---|---| | Heartbeat interval sent to members | `group.consumer.heartbeat.interval.ms` | 5000 ms, bounded by `group.consumer.min.heartbeat.interval.ms` (5000) and `group.consumer.max.heartbeat.interval.ms` (15000) | | Session timeout | `group.consumer.session.timeout.ms` | 45000 ms, bounded by `group.consumer.min.session.timeout.ms` (45000) and `group.consumer.max.session.timeout.ms` (60000) | | Available assignors | `group.consumer.assignors` | `uniform`, `range`; the first in the list is the default | | Maximum members per group | `group.consumer.max.size` | unlimited (`Integer.MAX_VALUE`) | Points worth knowing about these: - The heartbeat interval is not a client setting at all any more: every `ConsumerGroupHeartbeat` response carries `HeartbeatIntervalMs`, and the client follows it. - A single group can override the cluster value with the group-level configs `consumer.session.timeout.ms` and `consumer.heartbeat.interval.ms`, set through `kafka-configs.sh` on the group entity; the coordinator validates them against the broker's min/max bounds. With the defaults, a group cannot go below a 45-second session timeout without first lowering the broker minimum. - **Custom assignors** now live on the broker: implement `ConsumerGroupPartitionAssignor` and list its class name in `group.consumer.assignors`. Custom client-side assignors are not supported by the consumer protocol. ## What the client still sets - `group.protocol=consumer` itself. - `group.remote.assignor`: the **name** of a server-side assignor, for example `range`. If unset, the coordinator uses the first entry of `group.consumer.assignors`. The client sends it in the `ServerAssignor` heartbeat field; an unknown name is rejected with `UNSUPPORTED_ASSIGNOR`. - `max.poll.interval.ms`: sent as `RebalanceTimeoutMs`, the time the coordinator waits for the member to revoke partitions; a member that has not finished revoking within it is fenced. - `group.instance.id` and `client.rack` keep their meaning and travel in the heartbeat. The Kafka docs map old client-side assignors to server-side ones: `RangeAssignor` to `range`, and `RoundRobinAssignor`, `StickyAssignor` and `CooperativeStickyAssignor` to `uniform`. The `uniform` assignor puts balance first and stickiness second; `range` hands out contiguous ranges and lines up the same partition numbers across topics when co-partitioning is possible. ## What stops working The client fails fast rather than ignoring old settings. In `ConsumerConfig`, a consumer built with `group.protocol=consumer` throws a `ConfigException` reading "... cannot be set when group.protocol=CONSUMER" if any of these is present: 1. `partition.assignment.strategy` 2. `heartbeat.interval.ms` 3. `session.timeout.ms` The reverse check exists too: `group.remote.assignor` cannot be set when `group.protocol=classic`. The `enforceRebalance()` and `enforceRebalance(String)` methods do not throw; in the new consumer they log "Operation not supported in new consumer group protocol" and do nothing. Code that relied on them to force a reshuffle silently loses that behaviour. ## Server-side regex subscription The consumer protocol adds `subscribe(SubscriptionPattern)` and `subscribe(SubscriptionPattern, ConsumerRebalanceListener)`. The pattern must be in **RE2/J** syntax, travels in the `SubscribedTopicRegex` heartbeat field, and is resolved by the coordinator, which refreshes the matching topic set every `group.consumer.regex.refresh.interval.ms` (default 10 minutes). An invalid pattern surfaces as an `InvalidRegularExpression` on a later `poll()`. The older `subscribe(java.util.regex.Pattern)` still compiles and works; that form is still matched in the client against topic metadata, and the client sends the resolved topic names. ### The client side changes too When `group.protocol=consumer` is set, the `KafkaConsumer` also runs an improved internal threading model, in which a background thread handles the group and network work instead of the application thread inside `poll()`. The Kafka docs note new consumer metrics that expose it. `ConsumerRebalanceListener` callbacks still run on the application thread during `poll()`, so slow callbacks still delay revocation. ## A practical checklist - Remove the three rejected configs from every deployment's properties, including shared defaults files. - Map the old assignor to `group.remote.assignor` (`range` if you depended on `RangeAssignor`'s co-partitioning). - Ask the cluster operator what `group.consumer.session.timeout.ms` and heartbeat interval are, since they now govern failure detection for your group. - Search the code for `enforceRebalance` calls.
- Your team needs a shorter failure-detection time for one latency-sensitive group under the consumer protocol. What can you do?Set the group-level `consumer.session.timeout.ms` on that group with `kafka-configs.sh`, instead of a client setting. The coordinator validates it against `group.consumer.min.session.timeout.ms`, which defaults to 45000 ms, so going below 45 seconds also needs the broker minimum lowered by the cluster operator.
- What happens if a consumer names an assignor the broker does not have in group.remote.assignor?The coordinator rejects the heartbeat with the `UNSUPPORTED_ASSIGNOR` error, so the member does not join. The fix is either to use a name listed in the broker's `group.consumer.assignors` or to have the operator deploy the custom `ConsumerGroupPartitionAssignor` class and add it there.
- Under group.protocol=consumer you still tune session.timeout.ms in the client
- Old partition.assignment.strategy values are silently ignored under the new protocol
- group.remote.assignor takes a fully qualified client-side assignor class name
- max.poll.interval.ms has no role under the consumer protocol
- enforceRebalance() still triggers a rebalance under the consumer protocol
Assumes Kafka 4.0 or later, where the consumer protocol is GA; config names and defaults checked against the 4.3.1 source.