OffsetFetch
This page encodes the smallest legal instance of the request and the response: numeric fields are zero, strings and byte arrays are empty, every array carries exactly one sample element, and any records field holds one empty 61-byte RecordBatch v2. Version 9 is a flexible version, so every struct is terminated by a uvarint tagged-field count and strings and arrays carry compact length-plus-one prefixes. Sizes below include the leading int32 size prefix.
- API key
- 9
- Encoded at
- v9
- Flexible versions
- 6+
- Headers
- req v2, resp v1
- Request versions
- 1-9
- Response versions
- 1-9
- Request size
- 33 bytes
- Response size
- 43 bytes
framerpc headerrequest bodyRecordBatchRecordresponse bodytagged_fields
Request
OffsetFetchRequest v9, request header v2, 33 bytes on the wire
byte layout (33 bytes, 16 bytes per row)
0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F
0000
0010
0020
object tree
OffsetFetchRequest message v9 [0x0000, 33B] +-- Frame [0x0000, 4B] length-delimited framing | +-- size int32 = 29 [0x0000, 4B] number of bytes that follow, patched after encoding +-- RequestHeader v2 [0x0004, 11B] common request header | +-- request_api_key int16 = 9 (OffsetFetch) [0x0004, 2B] numeric id of the API being invoked | +-- request_api_version int16 = 9 [0x0006, 2B] version of the API being invoked | +-- correlation_id int32 = 0 [0x0008, 4B] echoed back by the broker in the response | +-- client_id nullable_string = "" (int16 len=0) [0x000c, 2B] always a non-flexible int16-prefixed string | +-- tagged_fields uvarint = 0 [0x000e, 1B] number of tagged fields in the header +-- OffsetFetchRequest struct [0x000f, 18B] message body, version 9 +-- Groups []OffsetFetchRequestGroup = 1 element [0x000f, 16B] Each group we would like to fetch offsets for. | +-- length uvarint = 2 (compact, n+1) [0x000f, 1B] one sample element follows | +-- OffsetFetchRequestGroup[0] OffsetFetchRequestGroup = struct [0x0010, 15B] | +-- GroupId string = "" (compact, len+1=1) [0x0010, 1B] The group ID. | +-- MemberId string = "" (compact, len+1=1) [0x0011, 1B] The member id. | +-- MemberEpoch int32 = 0 [0x0012, 4B] The member epoch if using the new consumer protocol (KIP-848). | +-- Topics []OffsetFetchRequestTopics = 1 element [0x0016, 8B] Each topic we would like to fetch offsets for, or null to fetch offsets for... | | +-- length uvarint = 2 (compact, n+1) [0x0016, 1B] one sample element follows | | +-- OffsetFetchRequestTopics[0] OffsetFetchRequestTopics = struct [0x0017, 7B] | | +-- Name string = "" (compact, len+1=1) [0x0017, 1B] The topic name. | | +-- PartitionIndexes []int32 = 1 element [0x0018, 5B] The partition indexes we would like to fetch offsets for. | | | +-- length uvarint = 2 (compact, n+1) [0x0018, 1B] one sample element follows | | | +-- int32[0] int32 = 0 [0x0019, 4B] | | +-- tagged_fields uvarint = 0 [0x001d, 1B] number of tagged fields in this struct | +-- tagged_fields uvarint = 0 [0x001e, 1B] number of tagged fields in this struct +-- RequireStable bool = false [0x001f, 1B] Whether broker should hold on returning unstable offsets but set a retriabl... +-- tagged_fields uvarint = 0 [0x0020, 1B] number of tagged fields in this struct
kafka message schema (.json)
{ "apiKey": 9, "type": "request", "listeners": ["broker"], "name": "OffsetFetchRequest", // Version 0 was removed in Apache Kafka 4.0, Version 1 is the new baseline. // // In version 0, the request read offsets from ZK. // // Starting in version 1, the broker supports fetching offsets from the internal __consumer_offsets topic. // // Starting in version 2, the request can contain a null topics array to indicate that offsets // for all topics should be fetched. It also returns a top level error code // for group or coordinator level errors. // // Version 3, 4, and 5 are the same as version 2. // // Version 6 is the first flexible version. // // Version 7 is adding the require stable flag. // // Version 8 is adding support for fetching offsets for multiple groups at a time. // // Version 9 is the first version that can be used with the new consumer group protocol (KIP-848). It adds // the MemberId and MemberEpoch fields. Those are filled in and validated when the new consumer protocol is used. "validVersions": "1-9", "flexibleVersions": "6+", "fields": [ { "name": "GroupId", "type": "string", "versions": "0-7", "entityType": "groupId", "about": "The group to fetch offsets for." }, { "name": "Topics", "type": "[]OffsetFetchRequestTopic", "versions": "0-7", "nullableVersions": "2-7", "about": "Each topic we would like to fetch offsets for, or null to fetch offsets for all topics.", "fields": [ { "name": "Name", "type": "string", "versions": "0-7", "entityType": "topicName", "about": "The topic name."}, { "name": "PartitionIndexes", "type": "[]int32", "versions": "0-7", "about": "The partition indexes we would like to fetch offsets for." } ]}, { "name": "Groups", "type": "[]OffsetFetchRequestGroup", "versions": "8+", "about": "Each group we would like to fetch offsets for.", "fields": [ { "name": "GroupId", "type": "string", "versions": "8+", "entityType": "groupId", "about": "The group ID."}, { "name": "MemberId", "type": "string", "versions": "9+", "nullableVersions": "9+", "default": "null", "ignorable": true, "about": "The member id." }, { "name": "MemberEpoch", "type": "int32", "versions": "9+", "default": "-1", "ignorable": true, "about": "The member epoch if using the new consumer protocol (KIP-848)." }, { "name": "Topics", "type": "[]OffsetFetchRequestTopics", "versions": "8+", "nullableVersions": "8+", "about": "Each topic we would like to fetch offsets for, or null to fetch offsets for all topics.", "fields": [ { "name": "Name", "type": "string", "versions": "8+", "entityType": "topicName", "about": "The topic name."}, { "name": "PartitionIndexes", "type": "[]int32", "versions": "8+", "about": "The partition indexes we would like to fetch offsets for." } ]} ]}, { "name": "RequireStable", "type": "bool", "versions": "7+", "default": "false", "about": "Whether broker should hold on returning unstable offsets but set a retriable error code for the partitions." } ] }
Response
OffsetFetchResponse v9, response header v1, 43 bytes on the wire
byte layout (43 bytes, 16 bytes per row)
0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F
0000
0010
0020
object tree
OffsetFetchResponse message v9 [0x0000, 43B] +-- Frame [0x0000, 4B] length-delimited framing | +-- size int32 = 39 [0x0000, 4B] number of bytes that follow, patched after encoding +-- ResponseHeader v1 [0x0004, 5B] common response header | +-- correlation_id int32 = 0 [0x0004, 4B] matches the correlation_id of the request | +-- tagged_fields uvarint = 0 [0x0008, 1B] number of tagged fields in the header +-- OffsetFetchResponse struct [0x0009, 34B] message body, version 9 +-- ThrottleTimeMs int32 = 0 [0x0009, 4B] The duration in milliseconds for which the request was throttled due to a q... +-- Groups []OffsetFetchResponseGroup = 1 element [0x000d, 29B] The responses per group id. | +-- length uvarint = 2 (compact, n+1) [0x000d, 1B] one sample element follows | +-- OffsetFetchResponseGroup[0] OffsetFetchResponseGroup = struct [0x000e, 28B] | +-- GroupId string = "" (compact, len+1=1) [0x000e, 1B] The group ID. | +-- Topics []OffsetFetchResponseTopics = 1 element [0x000f, 24B] The responses per topic. | | +-- length uvarint = 2 (compact, n+1) [0x000f, 1B] one sample element follows | | +-- OffsetFetchResponseTopics[0] OffsetFetchResponseTopics = struct [0x0010, 23B] | | +-- Name string = "" (compact, len+1=1) [0x0010, 1B] The topic name. | | +-- Partitions []OffsetFetchResponsePartitions = 1 element [0x0011, 21B] The responses per partition. | | | +-- length uvarint = 2 (compact, n+1) [0x0011, 1B] one sample element follows | | | +-- OffsetFetchResponsePartitions[0] OffsetFetchResponsePartitions = struct [0x0012, 20B] | | | +-- PartitionIndex int32 = 0 [0x0012, 4B] The partition index. | | | +-- CommittedOffset int64 = 0 [0x0016, 8B] The committed message offset. | | | +-- CommittedLeaderEpoch int32 = 0 [0x001e, 4B] The leader epoch. | | | +-- Metadata string = "" (compact, len+1=1) [0x0022, 1B] The partition metadata. | | | +-- ErrorCode int16 = 0 [0x0023, 2B] The partition-level error code, or 0 if there was no error. | | | +-- tagged_fields uvarint = 0 [0x0025, 1B] number of tagged fields in this struct | | +-- tagged_fields uvarint = 0 [0x0026, 1B] number of tagged fields in this struct | +-- ErrorCode int16 = 0 [0x0027, 2B] The group-level error code, or 0 if there was no error. | +-- tagged_fields uvarint = 0 [0x0029, 1B] number of tagged fields in this struct +-- tagged_fields uvarint = 0 [0x002a, 1B] number of tagged fields in this struct
kafka message schema (.json)
{ "apiKey": 9, "type": "response", "name": "OffsetFetchResponse", // Version 0 was removed in Apache Kafka 4.0, Version 1 is the new baseline. // // Version 1 is the same as version 0. // // Version 2 adds a top-level error code. // // Version 3 adds the throttle time. // // Starting in version 4, on quota violation, brokers send out responses before throttling. // // Version 5 adds the leader epoch to the committed offset. // // Version 6 is the first flexible version. // // Version 7 adds pending offset commit as new error response on partition level. // // Version 8 is adding support for fetching offsets for multiple groups // // Version 9 is the first version that can be used with the new consumer group protocol (KIP-848). The response is // the same as version 8 but can return STALE_MEMBER_EPOCH and UNKNOWN_MEMBER_ID errors when the new consumer group // protocol is used. "validVersions": "1-9", "flexibleVersions": "6+", // Supported errors: // - GROUP_AUTHORIZATION_FAILED (version 0+) // - NOT_COORDINATOR (version 0+) // - COORDINATOR_NOT_AVAILABLE (version 0+) // - COORDINATOR_LOAD_IN_PROGRESS (version 0+) // - GROUP_ID_NOT_FOUND (version 0+) // - UNSTABLE_OFFSET_COMMIT (version 7+) // - UNKNOWN_MEMBER_ID (version 9+) // - STALE_MEMBER_EPOCH (version 9+) "fields": [ { "name": "ThrottleTimeMs", "type": "int32", "versions": "3+", "ignorable": true, "about": "The duration in milliseconds for which the request was throttled due to a quota violation, or zero if the request did not violate any quota." }, { "name": "Topics", "type": "[]OffsetFetchResponseTopic", "versions": "0-7", "about": "The responses per topic.", "fields": [ { "name": "Name", "type": "string", "versions": "0-7", "entityType": "topicName", "about": "The topic name." }, { "name": "Partitions", "type": "[]OffsetFetchResponsePartition", "versions": "0-7", "about": "The responses per partition.", "fields": [ { "name": "PartitionIndex", "type": "int32", "versions": "0-7", "about": "The partition index." }, { "name": "CommittedOffset", "type": "int64", "versions": "0-7", "about": "The committed message offset." }, { "name": "CommittedLeaderEpoch", "type": "int32", "versions": "5-7", "default": "-1", "ignorable": true, "about": "The leader epoch." }, { "name": "Metadata", "type": "string", "versions": "0-7", "nullableVersions": "0-7", "about": "The partition metadata." }, { "name": "ErrorCode", "type": "int16", "versions": "0-7", "about": "The error code, or 0 if there was no error." } ]} ]}, { "name": "ErrorCode", "type": "int16", "versions": "2-7", "default": "0", "ignorable": true, "about": "The top-level error code, or 0 if there was no error." }, { "name": "Groups", "type": "[]OffsetFetchResponseGroup", "versions": "8+", "about": "The responses per group id.", "fields": [ { "name": "GroupId", "type": "string", "versions": "8+", "entityType": "groupId", "about": "The group ID." }, { "name": "Topics", "type": "[]OffsetFetchResponseTopics", "versions": "8+", "about": "The responses per topic.", "fields": [ { "name": "Name", "type": "string", "versions": "8+", "entityType": "topicName", "about": "The topic name." }, { "name": "Partitions", "type": "[]OffsetFetchResponsePartitions", "versions": "8+", "about": "The responses per partition.", "fields": [ { "name": "PartitionIndex", "type": "int32", "versions": "8+", "about": "The partition index." }, { "name": "CommittedOffset", "type": "int64", "versions": "8+", "about": "The committed message offset." }, { "name": "CommittedLeaderEpoch", "type": "int32", "versions": "8+", "default": "-1", "ignorable": true, "about": "The leader epoch." }, { "name": "Metadata", "type": "string", "versions": "8+", "nullableVersions": "8+", "about": "The partition metadata." }, { "name": "ErrorCode", "type": "int16", "versions": "8+", "about": "The partition-level error code, or 0 if there was no error." } ]} ]}, { "name": "ErrorCode", "type": "int16", "versions": "8+", "default": "0", "about": "The group-level error code, or 0 if there was no error." } ]} ] }