What is InitProducerId?
Every idempotent or transactional producer calls this before sending records to obtain a producer ID and epoch. The epoch prevents zombie producers: a restarted instance bumps the epoch, and late-arriving writes from the old instance are rejected with INVALID_PRODUCER_EPOCH.
Wire Diagram
Request Header · flexible
message_size
int32 · 4B
api_key
int16 · 2B
api_version
int16 · 2B
correlation_id
int32 · 4B
client_id
string (compact)
tagged
var
InitProducerIdRequest v6
TransactionalId?
string (compact)
TransactionTimeoutMs
int32 · 4B
ProducerId
int64 · 8B
ProducerEpoch
int16 · 2B
Enable2Pc
bool · 1B
KeepPreparedTxn
bool · 1B
tagged
var
Schema & Example
Schema { "TransactionalId": string?, "TransactionTimeoutMs": int32, "ProducerId": int64, "ProducerEpoch": int16, "Enable2Pc": bool, "KeepPreparedTxn": bool }
Example { "TransactionalId": null, "TransactionTimeoutMs": 5000, "ProducerId": 0, "ProducerEpoch": 12, "Enable2Pc": true, "KeepPreparedTxn": true }