0
0
Kafkadevops~10 mins

Producer retries and idempotency in Kafka - Interactive Code Practice

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

Complete the code to enable idempotence for the Kafka producer.

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'
Aacks
Benable.idempotence
Cretries
Dmax.in.flight.requests.per.connection
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'acks' instead of 'enable.idempotence'.
Setting 'retries' to true (it's a number, not boolean).
2fill in blank
medium

Complete the code to set the number of retries for the Kafka producer.

Kafka
Properties props = new Properties();
props.put("bootstrap.servers", "localhost:9092");
props.put("retries", "[1]");
Drag options to blanks, or click blank then click option'
A3
B-1
C0
Dtrue
Attempts:
3 left
💡 Hint
Common Mistakes
Using boolean values like 'true' for retries.
Setting retries to '-1' which means infinite retries but is less common.
3fill in blank
hard

Fix the error in the code to ensure safe retries with idempotency.

Kafka
props.put("max.in.flight.requests.per.connection", "[1]");
Drag options to blanks, or click blank then click option'
A0
B10
C5
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Using higher values like 5 or 10 which can cause message reordering.
Setting it to 0 which is invalid.
4fill in blank
hard

Fill both blanks to configure the producer for idempotent retries with proper acknowledgments.

Kafka
props.put("[1]", "all");
props.put("[2]", "true");
Drag options to blanks, or click blank then click option'
Aacks
Benable.idempotence
Cretries
Dmax.in.flight.requests.per.connection
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing 'retries' with 'acks'.
Not enabling idempotence while setting acks to 'all'.
5fill in blank
hard

Fill all three blanks to create a Kafka producer configuration that safely retries with idempotency and limits in-flight requests.

Kafka
props.put("[1]", "true");
props.put("[2]", "3");
props.put("[3]", "1");
Drag options to blanks, or click blank then click option'
Aenable.idempotence
Bretries
Cmax.in.flight.requests.per.connection
Dacks
Attempts:
3 left
💡 Hint
Common Mistakes
Setting 'acks' instead of 'max.in.flight.requests.per.connection' for the last property.
Not enabling idempotence while setting retries.