After discovering the location of its coordinator, the next step is to retrieve the producer’s ID. This is achieved by issuing an initProducerId to the transaction coordinator.
In addition to returning the ID, the initProducerId performs the following tasks:
Bumps up the epoch of the ID, so that any previous zombie instance of the producer is fenced off and cannot move forward with its transaction.
Recovers (rolls forward or rolls back) any transaction left incomplete by the previous instance of the producer.
The handling of theinitProducerId is synchronous. Once it returns, the producer can send data and start new transactions.
When an TransactionalId is not specified:
If no TransactionalId is specified in the configuration, a fresh ID is assigned, and the producer only enjoys idempotent semantics and transactional semantics within a single session.
After discovering the location of its coordinator, the next step is to retrieve the producer’s ID. This is achieved by issuing an
initProducerId
to the transaction coordinator.In addition to returning the ID, the initProducerId performs the following tasks:
initProducerId
is synchronous. Once it returns, the producer can send data and start new transactions.When an TransactionalId is not specified: If no TransactionalId is specified in the configuration, a fresh ID is assigned, and the producer only enjoys idempotent semantics and transactional semantics within a single session.
https://kafka.apache.org/protocol.html#The_Messages_InitProducerId