OpenSearch Consumer Flashcards
What does ‘At most once’ delivery semantics mean?
Offsets are committed as soon as the message batch is received. If the processing goes wrong, the message will be lost (it won’t be read again).
What does ‘At least once’ delivery semantics mean?
Offsets are committed after the message is processed. If the processing goes wrong, the message will be read again, which can result in duplicate processing of messages. Make sure to use idempotent!
What does ‘Exactly once’ delivery semantics mean?
Can be achieved for Kafka workflows using the Transactional API (easy with Kafka Streams API). For Kafka Sink workflows, use an idempotent consumer.
What are the two common patterns for committing offsets in a consumer application?
-
enable.auto.commit = true
& synchronous processing of batches (easy) -
enable.auto.commit = false
& manual commit of offsets (medium)
What happens with auto-commit in the first pattern?
Offsets will be committed automatically at regular intervals (auto.commit.interval.ms=5000
by default) every time you call .poll()
. If you don’t use synchronous processing, you will be in ‘at-most-once’ behavior.
What does the second pattern allow you to do?
You can control when you commit offsets and the condition for committing them.
Example: accumulating records into a buffer and then flushing the buffer to a database + committing offsets asynchronously.