0
0
Kafkadevops~10 mins

Auto-commit vs manual commit in Kafka - Interactive Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to enable auto-commit in Kafka consumer configuration.

Kafka
props.put("enable.auto.commit", [1]);
Drag options to blanks, or click blank then click option'
A"true"
B"auto"
C"false"
D"manual"
Attempts:
3 left
💡 Hint
Common Mistakes
Using false disables auto-commit.
Using 'auto' or 'manual' are invalid values.
2fill in blank
medium

Complete the code to manually commit offsets synchronously in Kafka consumer.

Kafka
consumer.[1]();
Drag options to blanks, or click blank then click option'
Acommit
BcommitSync
CcommitAsync
DcommitManual
Attempts:
3 left
💡 Hint
Common Mistakes
Using commitAsync commits asynchronously, not synchronously.
Using commit or commitManual are not valid Kafka consumer methods.
3fill in blank
hard

Fix the error in the code to disable auto-commit in Kafka consumer configuration.

Kafka
props.put("enable.auto.commit", [1]);
Drag options to blanks, or click blank then click option'
A"false"
Bfalse
CFalse
DFALSE
Attempts:
3 left
💡 Hint
Common Mistakes
Using boolean false without quotes causes errors.
Using capitalized False or FALSE are invalid.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps topic partitions to their latest committed offsets.

Kafka
offsets = {tp: consumer.[1](tp) for tp in consumer.[2]() if tp is not None}
Drag options to blanks, or click blank then click option'
Acommitted
Bassignment
Csubscription
Dpartitions
Attempts:
3 left
💡 Hint
Common Mistakes
Using subscription or partitions instead of assignment for getting assigned partitions.
Using wrong method names for committed offsets.
5fill in blank
hard

Fill all three blanks to commit offsets asynchronously with a callback that prints success or error.

Kafka
consumer.[1](offsets, new OffsetCommitCallback() {
    public void onComplete(Map<TopicPartition, OffsetAndMetadata> offsets, Exception e) {
        if (e == null) {
            System.out.println("Commit successful for [2]");
        } else {
            System.err.println("Commit failed: " + [3]);
        }
    }
});
Drag options to blanks, or click blank then click option'
AcommitAsync
Boffsets
Ce.getMessage()
DcommitSync
Attempts:
3 left
💡 Hint
Common Mistakes
Using commitSync instead of commitAsync for asynchronous commit.
Printing the exception object directly instead of its message.