Skip to content

Instantly share code, notes, and snippets.

@skynyrd
Created December 16, 2017 12:47
Show Gist options
  • Save skynyrd/f046bbd039a0cc3c1618f61a0ee452f7 to your computer and use it in GitHub Desktop.
Save skynyrd/f046bbd039a0cc3c1618f61a0ee452f7 to your computer and use it in GitHub Desktop.
consumer commit
try {
while (running) {
ConsumerRecords<String, String> records = consumer.poll(1000);
try {
for (ConsumerRecord<String, String> record : records)
// Your work here.
} catch (CommitFailedException e) {
// application specific failure handling
}
consumer.commitSync(); // THATS IT!
}
} finally {
consumer.close();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment