Created
December 16, 2017 12:47
-
-
Save skynyrd/f046bbd039a0cc3c1618f61a0ee452f7 to your computer and use it in GitHub Desktop.
consumer commit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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