CCDAK · Question #54
What kind of delivery guarantee this consumer offers? while (true) { ConsumerRecords<String, String> records = consumer.poll(100); try { consumer.commitSync(); } catch (CommitFailedException e) {…
The correct answer is C. At-most-once. Here offset is committed before processing the message. If consumer crashes before processing the message, message will be lost when it comes back up.
Question
What kind of delivery guarantee this consumer offers? while (true) { ConsumerRecords<String, String> records = consumer.poll(100); try { consumer.commitSync(); } catch (CommitFailedException e) { log.error("commit failed", e) } for (ConsumerRecord<String, String> record records) { System.out.printf("topic = %s, partition = %s, offset = %d, customer = %s, country = %s ", record.topic(), record.partition(), record.offset(), record.key(), record.value()); } }
Options
- AExactly-once
- BAt-least-once
- CAt-most-once
How the community answered
(21 responses)- A14% (3)
- B29% (6)
- C57% (12)
Explanation
Here offset is committed before processing the message. If consumer crashes before processing the message, message will be lost when it comes back up.
Topics
Community Discussion
No community discussion yet for this question.