tulios / kafkajs

A modern Apache Kafka client for node.js
https://kafka.js.org
MIT License
3.7k stars 523 forks source link

Add protocol initProducerId v0 #166

Closed tulios closed 5 years ago

tulios commented 5 years ago

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:

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.

InitProducerId Request (Version: 0) => transactional_id transaction_timeout_ms 
  transactional_id => NULLABLE_STRING
  transaction_timeout_ms => INT32
InitProducerId Response (Version: 0) => throttle_time_ms error_code producer_id producer_epoch 
  throttle_time_ms => INT32
  error_code => INT16
  producer_id => INT64
  producer_epoch => INT16

https://kafka.apache.org/protocol.html#The_Messages_InitProducerId

ianwsperber commented 5 years ago

Beginning work implementing protocol and exposing in broker.