Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to enable idempotence in the Kafka producer configuration.
Kafka
Properties props = new Properties(); props.put("bootstrap.servers", "localhost:9092"); props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer"); props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer"); props.put("[1]", "true");
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'acks' instead of 'enable.idempotence' to enable idempotence.
Setting 'retries' to true, which is invalid.
Confusing 'max.in.flight.requests.per.connection' with the idempotence setting.
✗ Incorrect
Setting 'enable.idempotence' to 'true' enables the idempotent producer feature in Kafka, ensuring exactly-once delivery.
2fill in blank
mediumComplete the code to set the maximum number of retries for the idempotent producer.
Kafka
props.put("[1]", 5);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'acks' instead of 'retries' to set retry count.
Setting 'enable.idempotence' to a number instead of a boolean.
Confusing 'max.in.flight.requests.per.connection' with retry count.
✗ Incorrect
The 'retries' configuration sets how many times the producer will retry sending a message if it fails.
3fill in blank
hardFix the error in the code to limit the number of in-flight requests for idempotent producer.
Kafka
props.put("max.in.flight.requests.per.connection", [1]);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the number as a string instead of an integer.
Using boolean values instead of an integer.
Confusing this setting with 'enable.idempotence'.
✗ Incorrect
The value for 'max.in.flight.requests.per.connection' must be an integer, not a string or boolean.
4fill in blank
hardFill both blanks to configure the producer for idempotent delivery with correct acknowledgments.
Kafka
props.put("[1]", "true"); props.put("[2]", "all");
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing 'retries' with 'acks' in these positions.
Setting 'acks' to a boolean value instead of 'all'.
Not enabling idempotence but setting 'acks' to 'all'.
✗ Incorrect
To ensure idempotent delivery, 'enable.idempotence' must be true and 'acks' set to 'all' for full acknowledgment.
5fill in blank
hardFill all three blanks to complete the idempotent producer configuration with retries and in-flight request limits.
Kafka
props.put("[1]", "true"); props.put("[2]", 3); props.put("[3]", 1);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Setting 'acks' instead of 'max.in.flight.requests.per.connection' for the last blank.
Using string values for numeric settings.
Not enabling idempotence but setting retries and in-flight requests.
✗ Incorrect
Enable idempotence, set retries to 3, and limit max in-flight requests to 1 for safe idempotent producer configuration.