Skip to content
m manifester.io
All Kafka APIs

InitProducerId

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 5 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
22
Encoded at
v5
Flexible versions
2+
Headers
req v2, resp v1
Request versions
0-5
Response versions
0-5
Request size
31 bytes
Response size
26 bytes
framerpc headerrequest bodyRecordBatchRecordresponse bodytagged_fields

Request

InitProducerIdRequest v5, request header v2, 31 bytes on the wire

byte layout (31 bytes, 16 bytes per row)

0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F
0000
0010

object tree

InitProducerIdRequest         message v5                                [0x0000, 31B]
+-- Frame                                                               [0x0000, 4B]   length-delimited framing
|   +-- size                  int32            = 27                     [0x0000, 4B]   number of bytes that follow, patched after encoding
+-- RequestHeader             v2                                        [0x0004, 11B]  common request header
|   +-- request_api_key       int16            = 22 (InitProducerId)    [0x0004, 2B]   numeric id of the API being invoked
|   +-- request_api_version   int16            = 5                      [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
+-- InitProducerIdRequest     struct                                    [0x000f, 16B]  message body, version 5
    +-- TransactionalId       string           = "" (compact, len+1=1)  [0x000f, 1B]   The transactional id, or null if the producer is not transactional.
    +-- TransactionTimeoutMs  int32            = 0                      [0x0010, 4B]   The time in ms to wait before aborting idle transactions sent by this produ...
    +-- ProducerId            int64            = 0                      [0x0014, 8B]   The producer id. This is used to disambiguate requests if a transactional i...
    +-- ProducerEpoch         int16            = 0                      [0x001c, 2B]   The producer's current epoch. This will be checked against the producer epo...
    +-- tagged_fields         uvarint          = 0                      [0x001e, 1B]   number of tagged fields in this struct

kafka message schema (.json)

{
  "apiKey": 22,
  "type": "request",
  "listeners": ["broker"],
  "name": "InitProducerIdRequest",
  // Version 1 is the same as version 0.
  //
  // Version 2 is the first flexible version.
  //
  // Version 3 adds ProducerId and ProducerEpoch, allowing producers to try to resume after an INVALID_PRODUCER_EPOCH error
  //
  // Version 4 adds the support for new error code PRODUCER_FENCED.
  //
  // Verison 5 adds support for new error code TRANSACTION_ABORTABLE (KIP-890).
  "validVersions": "0-5",
  "flexibleVersions": "2+",
  "fields": [
    { "name": "TransactionalId", "type": "string", "versions": "0+", "nullableVersions": "0+", "entityType": "transactionalId",
      "about": "The transactional id, or null if the producer is not transactional." },
    { "name": "TransactionTimeoutMs", "type": "int32", "versions": "0+",
      "about": "The time in ms to wait before aborting idle transactions sent by this producer. This is only relevant if a TransactionalId has been defined." },
    { "name": "ProducerId", "type": "int64", "versions": "3+", "default": "-1", "entityType": "producerId",
      "about": "The producer id. This is used to disambiguate requests if a transactional id is reused following its expiration." },
    { "name": "ProducerEpoch", "type": "int16", "versions": "3+", "default": "-1",
      "about": "The producer's current epoch. This will be checked against the producer epoch on the broker, and the request will return an error if they do not match." }
  ]
}

Response

InitProducerIdResponse v5, response header v1, 26 bytes on the wire

byte layout (26 bytes, 16 bytes per row)

0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F
0000
0010

object tree

InitProducerIdResponse      message v5        [0x0000, 26B]
+-- Frame                                     [0x0000, 4B]   length-delimited framing
|   +-- size                int32       = 22  [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
+-- InitProducerIdResponse  struct            [0x0009, 17B]  message body, version 5
    +-- ThrottleTimeMs      int32       = 0   [0x0009, 4B]   The duration in milliseconds for which the request was throttled due to a q...
    +-- ErrorCode           int16       = 0   [0x000d, 2B]   The error code, or 0 if there was no error.
    +-- ProducerId          int64       = 0   [0x000f, 8B]   The current producer id.
    +-- ProducerEpoch       int16       = 0   [0x0017, 2B]   The current epoch associated with the producer id.
    +-- tagged_fields       uvarint     = 0   [0x0019, 1B]   number of tagged fields in this struct

kafka message schema (.json)

{
  "apiKey": 22,
  "type": "response",
  "name": "InitProducerIdResponse",
  // Starting in version 1, on quota violation, brokers send out responses before throttling.
  //
  // Version 2 is the first flexible version.
  //
  // Version 3 is the same as version 2.
  //
  // Version 4 adds the support for new error code PRODUCER_FENCED.
  //
  // Version 5 adds support for new error code TRANSACTION_ABORTABLE (KIP-890).
  "validVersions": "0-5",
  "flexibleVersions": "2+",
  "fields": [
    { "name": "ThrottleTimeMs", "type": "int32", "versions": "0+", "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": "ErrorCode", "type": "int16", "versions": "0+",
      "about": "The error code, or 0 if there was no error." },
    { "name": "ProducerId", "type": "int64", "versions": "0+", "entityType": "producerId",
      "default": -1, "about": "The current producer id." },
    { "name": "ProducerEpoch", "type": "int16", "versions": "0+",
      "about": "The current epoch associated with the producer id." }
  ]
}