nerdexam
Confluent

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.

Developing Kafka Consumers

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)
  • A
    14% (3)
  • B
    29% (6)
  • C
    57% (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

#delivery semantics#at-most-once#commitSync#consumer offset

Community Discussion

No community discussion yet for this question.

Full CCDAK Practice