Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
KafkaProducer producer = createKafkaProducer(
bootstrap.servers”, “localhost:9092”,
transactional.id”, “my-transactional-id”);
producer.initTransactions();
// Do Something
producer.beginTransaction();
producer.send(producerRecord(“outputTopic”, record));
producer.sendOffsetsToTransaction(currentOffsets(consumer), group);
producer.commitTransaction();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment