Skip to content
m manifester.io
All Kafka APIs

AddPartitionsToTxn

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
24
Encoded at
v5
Flexible versions
3+
Headers
req v2, resp v1
Request versions
0-5
Response versions
0-5
Request size
38 bytes
Response size
30 bytes
framerpc headerrequest bodyRecordBatchRecordresponse bodytagged_fields

Request

AddPartitionsToTxnRequest v5, request header v2, 38 bytes on the wire

byte layout (38 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

AddPartitionsToTxnRequest                       message v5                                                  [0x0000, 38B]
+-- Frame                                                                                                   [0x0000, 4B]   length-delimited framing
|   +-- size                                    int32                            = 34                       [0x0000, 4B]   number of bytes that follow, patched after encoding
+-- RequestHeader                               v2                                                          [0x0004, 11B]  common request header
|   +-- request_api_key                         int16                            = 24 (AddPartitionsToTxn)  [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
+-- AddPartitionsToTxnRequest                   struct                                                      [0x000f, 23B]  message body, version 5
    +-- Transactions                            []AddPartitionsToTxnTransaction  = 1 element                [0x000f, 22B]  List of transactions to add partitions to.
    |   +-- length                              uvarint                          = 2 (compact, n+1)         [0x000f, 1B]   one sample element follows
    |   +-- AddPartitionsToTxnTransaction[0]    AddPartitionsToTxnTransaction    = struct                   [0x0010, 21B]
    |       +-- TransactionalId                 string                           = "" (compact, len+1=1)    [0x0010, 1B]   The transactional id corresponding to the transaction.
    |       +-- ProducerId                      int64                            = 0                        [0x0011, 8B]   Current producer id in use by the transactional id.
    |       +-- ProducerEpoch                   int16                            = 0                        [0x0019, 2B]   Current epoch associated with the producer id.
    |       +-- VerifyOnly                      bool                             = false                    [0x001b, 1B]   Boolean to signify if we want to check if the partition is in the transacti...
    |       +-- Topics                          []AddPartitionsToTxnTopic        = 1 element                [0x001c, 8B]   The partitions to add to the transaction.
    |       |   +-- length                      uvarint                          = 2 (compact, n+1)         [0x001c, 1B]   one sample element follows
    |       |   +-- AddPartitionsToTxnTopic[0]  AddPartitionsToTxnTopic          = struct                   [0x001d, 7B]
    |       |       +-- Name                    string                           = "" (compact, len+1=1)    [0x001d, 1B]   The name of the topic.
    |       |       +-- Partitions              []int32                          = 1 element                [0x001e, 5B]   The partition indexes to add to the transaction.
    |       |       |   +-- length              uvarint                          = 2 (compact, n+1)         [0x001e, 1B]   one sample element follows
    |       |       |   +-- int32[0]            int32                            = 0                        [0x001f, 4B]
    |       |       +-- tagged_fields           uvarint                          = 0                        [0x0023, 1B]   number of tagged fields in this struct
    |       +-- tagged_fields                   uvarint                          = 0                        [0x0024, 1B]   number of tagged fields in this struct
    +-- tagged_fields                           uvarint                          = 0                        [0x0025, 1B]   number of tagged fields in this struct

kafka message schema (.json)

{
  "apiKey": 24,
  "type": "request",
  "listeners": ["broker"],
  "name": "AddPartitionsToTxnRequest",
  // Version 1 is the same as version 0.
  //
  // Version 2 adds the support for new error code PRODUCER_FENCED.
  //
  // Version 3 enables flexible versions.
  //
  // Version 4 adds VerifyOnly field to check if partitions are already in transaction and adds support to batch multiple transactions.
  //
  // Version 5 adds support for new error code TRANSACTION_ABORTABLE (KIP-890).
  // Versions 3 and below will be exclusively used by clients and versions 4 and above will be used by brokers.
  "latestVersionUnstable": false,
  "validVersions": "0-5",
  "flexibleVersions": "3+",
  "fields": [
    { "name": "Transactions", "type": "[]AddPartitionsToTxnTransaction", "versions":  "4+",
      "about": "List of transactions to add partitions to.", "fields": [
      { "name": "TransactionalId", "type": "string", "versions": "4+", "mapKey": true, "entityType": "transactionalId",
        "about": "The transactional id corresponding to the transaction." },
      { "name": "ProducerId", "type": "int64", "versions": "4+", "entityType": "producerId",
        "about": "Current producer id in use by the transactional id." },
      { "name": "ProducerEpoch", "type": "int16", "versions": "4+",
        "about": "Current epoch associated with the producer id." },
      { "name": "VerifyOnly", "type": "bool", "versions": "4+", "default": false,
        "about": "Boolean to signify if we want to check if the partition is in the transaction rather than add it." },
      { "name": "Topics", "type": "[]AddPartitionsToTxnTopic", "versions": "4+",
        "about": "The partitions to add to the transaction." }
    ]},
    { "name": "V3AndBelowTransactionalId", "type": "string", "versions": "0-3", "entityType": "transactionalId",
      "about": "The transactional id corresponding to the transaction." },
    { "name": "V3AndBelowProducerId", "type": "int64", "versions": "0-3", "entityType": "producerId",
      "about": "Current producer id in use by the transactional id." },
    { "name": "V3AndBelowProducerEpoch", "type": "int16", "versions": "0-3",
      "about": "Current epoch associated with the producer id." },
    { "name": "V3AndBelowTopics", "type": "[]AddPartitionsToTxnTopic", "versions": "0-3",
      "about": "The partitions to add to the transaction." }
  ],
  "commonStructs": [
    { "name": "AddPartitionsToTxnTopic", "versions": "0+", "fields": [
      { "name": "Name", "type": "string", "versions": "0+", "mapKey": true, "entityType": "topicName",
        "about": "The name of the topic." },
      { "name": "Partitions", "type": "[]int32", "versions": "0+",
        "about": "The partition indexes to add to the transaction." }
    ]}
  ]
}

Response

AddPartitionsToTxnResponse v5, response header v1, 30 bytes on the wire

byte layout (30 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

AddPartitionsToTxnResponse                                        message v5                                                    [0x0000, 30B]
+-- Frame                                                                                                                       [0x0000, 4B]   length-delimited framing
|   +-- size                                                      int32                                = 26                     [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
+-- AddPartitionsToTxnResponse                                    struct                                                        [0x0009, 21B]  message body, version 5
    +-- ThrottleTimeMs                                            int32                                = 0                      [0x0009, 4B]   Duration in milliseconds for which the request was throttled due to a quota...
    +-- ErrorCode                                                 int16                                = 0                      [0x000d, 2B]   The response top level error code.
    +-- ResultsByTransaction                                      []AddPartitionsToTxnResult           = 1 element              [0x000f, 14B]  Results categorized by transactional ID.
    |   +-- length                                                uvarint                              = 2 (compact, n+1)       [0x000f, 1B]   one sample element follows
    |   +-- AddPartitionsToTxnResult[0]                           AddPartitionsToTxnResult             = struct                 [0x0010, 13B]
    |       +-- TransactionalId                                   string                               = "" (compact, len+1=1)  [0x0010, 1B]   The transactional id corresponding to the transaction.
    |       +-- TopicResults                                      []AddPartitionsToTxnTopicResult      = 1 element              [0x0011, 11B]  The results for each topic.
    |       |   +-- length                                        uvarint                              = 2 (compact, n+1)       [0x0011, 1B]   one sample element follows
    |       |   +-- AddPartitionsToTxnTopicResult[0]              AddPartitionsToTxnTopicResult        = struct                 [0x0012, 10B]
    |       |       +-- Name                                      string                               = "" (compact, len+1=1)  [0x0012, 1B]   The topic name.
    |       |       +-- ResultsByPartition                        []AddPartitionsToTxnPartitionResult  = 1 element              [0x0013, 8B]   The results for each partition.
    |       |       |   +-- length                                uvarint                              = 2 (compact, n+1)       [0x0013, 1B]   one sample element follows
    |       |       |   +-- AddPartitionsToTxnPartitionResult[0]  AddPartitionsToTxnPartitionResult    = struct                 [0x0014, 7B]
    |       |       |       +-- PartitionIndex                    int32                                = 0                      [0x0014, 4B]   The partition indexes.
    |       |       |       +-- PartitionErrorCode                int16                                = 0                      [0x0018, 2B]   The response error code.
    |       |       |       +-- tagged_fields                     uvarint                              = 0                      [0x001a, 1B]   number of tagged fields in this struct
    |       |       +-- tagged_fields                             uvarint                              = 0                      [0x001b, 1B]   number of tagged fields in this struct
    |       +-- tagged_fields                                     uvarint                              = 0                      [0x001c, 1B]   number of tagged fields in this struct
    +-- tagged_fields                                             uvarint                              = 0                      [0x001d, 1B]   number of tagged fields in this struct

kafka message schema (.json)

{
  "apiKey": 24,
  "type": "response",
  "name": "AddPartitionsToTxnResponse",
  // Starting in version 1, on quota violation brokers send out responses before throttling.
  //
  // Version 2 adds the support for new error code PRODUCER_FENCED.
  //
  // Version 3 enables flexible versions.
  //
  // Version 4 adds support to batch multiple transactions and a top level error code.
  //
  // Version 5 adds support for new error code TRANSACTION_ABORTABLE (KIP-890).
  "validVersions": "0-5",
  "flexibleVersions": "3+",
  "fields": [
    { "name": "ThrottleTimeMs", "type": "int32", "versions": "0+",
      "about": "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": "4+", "ignorable": true,
      "about": "The response top level error code." },
    { "name": "ResultsByTransaction", "type": "[]AddPartitionsToTxnResult", "versions": "4+",
      "about": "Results categorized by transactional ID.", "fields": [
      { "name": "TransactionalId", "type": "string", "versions": "4+", "mapKey": true, "entityType": "transactionalId",
        "about": "The transactional id corresponding to the transaction." },
      { "name": "TopicResults", "type": "[]AddPartitionsToTxnTopicResult", "versions": "4+",
        "about": "The results for each topic." }
    ]},
    { "name": "ResultsByTopicV3AndBelow", "type": "[]AddPartitionsToTxnTopicResult", "versions": "0-3",
      "about": "The results for each topic." }
  ],
  "commonStructs": [
    { "name": "AddPartitionsToTxnTopicResult", "versions": "0+", "fields": [
      { "name": "Name", "type": "string", "versions": "0+", "mapKey": true, "entityType": "topicName",
        "about": "The topic name." },
      { "name": "ResultsByPartition", "type": "[]AddPartitionsToTxnPartitionResult", "versions": "0+",
        "about": "The results for each partition." }
    ]},
    { "name": "AddPartitionsToTxnPartitionResult", "versions": "0+", "fields": [
      { "name": "PartitionIndex", "type": "int32", "versions": "0+", "mapKey": true,
        "about": "The partition indexes." },
      { "name": "PartitionErrorCode", "type": "int16", "versions": "0+",
        "about": "The response error code." }
    ]}
  ]
}