nerdexam
Confluent

CCDAK · Question #212

Your application is consuming from a topic configured with a deserializer. The application needs to be resilient to badly formatted records (poison pills) so you surround the 'poll()' call with a…

The correct answer is B. Log the bad record and seek the consumer to the offset of the next record. To handle poison pills properly, you should log the bad record and seek the consumer to the offset of the next record. This skips the problematic message and allows the consumer to continue processing without being stuck in a failure loop.

Developing Kafka Consumers

Question

Your application is consuming from a topic configured with a deserializer. The application needs to be resilient to badly formatted records (poison pills) so you surround the 'poll()' call with a try/catch block for 'RecordDeserializationException'. You need to log the bad record, skip it, and go on processing other records. Which action should you take in the catch block?

Options

  • ALog the bad record, no other action needed.
  • BLog the bad record and seek the consumer to the offset of the next record.
  • CLog the bad record and call the consumer.skip() method.
  • DThrow a runtime exception to trigger restart of the application.

How the community answered

(57 responses)
  • A
    4% (2)
  • B
    79% (45)
  • C
    5% (3)
  • D
    12% (7)

Explanation

To handle poison pills properly, you should log the bad record and seek the consumer to the offset of the next record. This skips the problematic message and allows the consumer to continue processing without being stuck in a failure loop.

Topics

#poison pill#RecordDeserializationException#consumer seek#error handling

Community Discussion

No community discussion yet for this question.

Full CCDAK Practice