Skip to content

Instantly share code, notes, and snippets.

@1ambda
Created December 29, 2021 13:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 1ambda/7bfbf4e747f137804ac42d74cba82ad2 to your computer and use it in GitHub Desktop.
Save 1ambda/7bfbf4e747f137804ac42d74cba82ad2 to your computer and use it in GitHub Desktop.
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