0
0
Kafkadevops~10 mins

Windowed operations 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 create a tumbling window of 5 minutes.

Kafka
KStream<String, String> windowedStream = stream.groupByKey().windowedBy(TimeWindows.of(Duration.[1](5))).count();
Drag options to blanks, or click blank then click option'
Aminutes
Bseconds
Chours
Ddays
Attempts:
3 left
💡 Hint
Common Mistakes
Using seconds instead of minutes causes a shorter window.
Using hours or days creates a much larger window than intended.
2fill in blank
medium

Complete the code to create a hopping window with size 10 minutes and advance interval 5 minutes.

Kafka
KStream<String, String> hoppingWindowedStream = stream.groupByKey().windowedBy(SlidingWindows.ofTimeDifferenceWithNoGrace(Duration.ofMinutes(10)).[1](Duration.ofMinutes(5))).count();
Drag options to blanks, or click blank then click option'
Agrace
BadvanceBy
Cuntil
Dsuppress
Attempts:
3 left
💡 Hint
Common Mistakes
Using grace() instead of advanceBy() changes grace period, not advance interval.
Using until() or suppress() are unrelated to window advance.
3fill in blank
hard

Fix the error in the code to set a session window with 15 minutes inactivity gap.

Kafka
KStream<String, String> sessionWindowedStream = stream.groupByKey().windowedBy(SessionWindows.[1](Duration.ofMinutes(15))).count();
Drag options to blanks, or click blank then click option'
AwithGap
BwithInactivityGap
Cwith
Dof
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-existent methods like withGap() or withInactivityGap() causes errors.
4fill in blank
hard

Fill both blanks to create a tumbling window of 1 minute and set a grace period of 30 seconds.

Kafka
KStream<String, String> windowedStream = stream.groupByKey().windowedBy(TimeWindows.of(Duration.[1](1)).[2](Duration.ofSeconds(30))).count();
Drag options to blanks, or click blank then click option'
Aminutes
Bseconds
Cgrace
DadvanceBy
Attempts:
3 left
💡 Hint
Common Mistakes
Using advanceBy instead of grace for grace period.
Using seconds for window size instead of minutes.
5fill in blank
hard

Fill all three blanks to create a hopping window of 15 minutes size, 5 minutes advance, and set a grace period of 1 minute.

Kafka
KStream<String, String> hoppingWindowedStream = stream.groupByKey().windowedBy(SlidingWindows.ofTimeDifferenceWithNoGrace(Duration.of[1](15)).[2](Duration.of[3](5))).grace(Duration.ofMinutes(1)).count();
Drag options to blanks, or click blank then click option'
AMinutes
BSeconds
Cminutes
DadvanceBy
Attempts:
3 left
💡 Hint
Common Mistakes
Using uppercase Minutes instead of lowercase minutes causes errors.
Confusing grace period setting with advance interval.