Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Transactions in Kafka is similar to Transactions in regular databases.

Code Block
breakoutModewide
languagejava
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
Note

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.