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.
| Version | Kafka | Changes |
|---|---|---|
| InitProducerIdRequest | ||
| v0 | 2.2 | + TransactionalId string+ TransactionTimeoutMs int32 |
| v1 | 2.2 | is the same as version 0. |
| v2 | 2.4 | ~ Flexible encoding enabled FLEXIBLE is the first flexible version. |
| v3 | 2.5 | + ProducerId int64+ ProducerEpoch int16adds ProducerId and ProducerEpoch, allowing producers to try to resume after an INVALID_PRODUCER_EPOCH error |
| v4 | 2.7 | adds the support for new error code PRODUCER_FENCED. |
| v5 | 3.8 | adds support for new error code TRANSACTION_ABORTABLE (KIP-890). |
| v6 | 4.1 | + Enable2Pc bool+ KeepPreparedTxn booladds support for 2PC (KIP-939). |
| InitProducerIdResponse | ||
| v0 | 2.2 | + ThrottleTimeMs int32+ ErrorCode int16+ ProducerId int64+ ProducerEpoch int16 |
| v1 | 2.2 | on quota violation, brokers send out responses before throttling. |
| v2 | 2.4 | ~ Flexible encoding enabled FLEXIBLE is the first flexible version. |
| v3 | 2.5 | is the same as version 2. |
| v4 | 2.7 | adds the support for new error code PRODUCER_FENCED. |
| v5 | 3.8 | adds support for new error code TRANSACTION_ABORTABLE (KIP-890). |
| v6 | 4.1 | + OngoingTxnProducerId int64+ OngoingTxnProducerEpoch int16adds support for 2PC (KIP-939). |