Delivery Semantics
There are different ways Consumers will handle delivery.
References
Flashcards
What are the 3 different ways Consumers handle message delivery?:: Atleast once, at most once, exactly once
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());
}
}
What kind of delivery guarantee this consumer offers?
?
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.