Confluent
CCDAK · Question #160
The producer code below features a 'Callback' class with a method called 'onCompletion()'. When will the 'onCompletion()' method be invoked?
The correct answer is D. When the producer receives the acknowledgment from the broker. The onCompletion() method of the Callback is invoked when the producer receives the acknowledgment from the broker, indicating that the message has been successfully written or an error has occurred.
Developing Kafka Producers
Question
The producer code below features a 'Callback' class with a method called 'onCompletion()'. When will the 'onCompletion()' method be invoked?
Exhibit
Options
- AWhen a consumer sends an acknowledgement to the producer
- BWhen the producer puts the message into its socket buffer
- CWhen the producer batches the message
- DWhen the producer receives the acknowledgment from the broker
How the community answered
(41 responses)- A7% (3)
- B2% (1)
- C2% (1)
- D88% (36)
Explanation
The onCompletion() method of the Callback is invoked when the producer receives the acknowledgment from the broker, indicating that the message has been successfully written or an error has occurred.
Topics
#Callback#onCompletion#broker acknowledgment#async producer
Community Discussion
No community discussion yet for this question.
