In Kafka, what is a key correctness concern when using at-least-once delivery guarantee?
Think about what happens if a message is retried after a failure.
At-least-once delivery means Kafka ensures messages are not lost but may deliver duplicates if retries occur. This can affect correctness if the consumer is not idempotent.
What will be the output count of messages processed if Kafka producer uses exactly-once semantics and the consumer commits offsets only after processing?
Assume 3 messages are sent and no failures occur.
producer.send('topic', 'msg1') producer.send('topic', 'msg2') producer.send('topic', 'msg3') consumer.process_and_commit_offsets()
Exactly-once semantics prevent duplicates and loss when configured properly.
With exactly-once semantics and proper offset commits after processing, each message is processed once and only once, so output count matches input count exactly.
Given the following Kafka consumer code snippet with at-most-once delivery, what is the possible output?
consumer.poll() consumer.commit_offsets() process_messages()
Assume a failure happens after commit but before processing.
Consider what happens if offsets are committed before processing.
At-most-once delivery commits offsets before processing, so if failure occurs after commit but before processing, messages are lost because consumer thinks they are done.
Which of the following best explains why achieving exactly-once delivery in Kafka is challenging?
Think about what happens when failures happen during message send or processing.
Exactly-once requires coordination between producer, broker, and consumer to handle retries and failures without duplicates or losses, which is complex due to network and system failures.
You have a Kafka consumer configured with at-least-once delivery. Which approach below best ensures your application maintains correctness despite possible duplicate messages?
Think about how to handle duplicates when they happen.
At-least-once delivery can cause duplicates, so the consumer must use idempotent processing or deduplication to maintain correctness.