Understanding of Transactions in Kafka
Transactions in Kafka is similar to Transactions in regular databases.
producer.beginTransaction();
producer.send(new ProducerRecord<>("A", "...", "..."));
producer.send(new ProducerRecord<>("B", "...", "..."));
producer.sendOffsetsToTransaction(offsets, group); // commit offsets in the topic a consumer is reading from
producer.commitTransaction(); // commit the offset to the special topic in Kafka
Transactions :
We get either all or nothing, we either commit both event no changes in Kafka topics are made.
Visible performance impact : only to use when we need them.
Â