Note |
---|
Transactions in Kafka is similar to Transactions in regular databases. |
Code Block | ||||
---|---|---|---|---|
| ||||
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(); |