Challenge - 5 Problems
Kafka Punctuator Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of a Punctuator with Fixed Interval
Consider a Kafka Streams application with a punctuator scheduled every 1000 milliseconds. What will be the output printed if the punctuator prints the current timestamp every time it triggers, and the stream runs for 3 seconds?
Kafka
streamsBuilder.stream("input-topic") .process(() -> new Processor<String, String>() { private ProcessorContext context; @Override public void init(ProcessorContext context) { this.context = context; this.context.schedule(Duration.ofMillis(1000), PunctuationType.WALL_CLOCK_TIME, timestamp -> { System.out.println("Punctuator triggered at: " + timestamp); }); } @Override public void process(String key, String value) {} @Override public void close() {} });
Attempts:
2 left
💡 Hint
Think about how often the punctuator is scheduled and how long the stream runs.
✗ Incorrect
The punctuator is scheduled to run every 1000 milliseconds (1 second). Since the stream runs for 3 seconds, the punctuator triggers approximately 3 times, printing the timestamp each time.
❓ Predict Output
intermediate2:00remaining
Behavior of STREAM_TIME Punctuator
What is the output behavior of a punctuator scheduled with PunctuationType.STREAM_TIME that triggers every 500 milliseconds in Kafka Streams?
Kafka
context.schedule(Duration.ofMillis(500), PunctuationType.STREAM_TIME, timestamp -> { System.out.println("Stream time punctuator at: " + timestamp); });
Attempts:
2 left
💡 Hint
STREAM_TIME punctuators depend on the progress of stream time, not wall-clock time.
✗ Incorrect
STREAM_TIME punctuators trigger only when the stream time (based on record timestamps) advances by the scheduled interval. They do not trigger based on wall-clock time.
🔧 Debug
advanced2:00remaining
Why does this Punctuator never trigger?
Given the following Kafka Streams punctuator code, why does the punctuator never print any output?
Kafka
context.schedule(Duration.ofMillis(1000), PunctuationType.STREAM_TIME, timestamp -> { System.out.println("Triggered at " + timestamp); });
Attempts:
2 left
💡 Hint
STREAM_TIME punctuators depend on stream time advancing.
✗ Incorrect
STREAM_TIME punctuators trigger only when stream time advances. If no records with increasing timestamps are processed, the punctuator never triggers.
🧠 Conceptual
advanced2:00remaining
Difference Between WALL_CLOCK_TIME and STREAM_TIME Punctuators
Which statement correctly describes the difference between WALL_CLOCK_TIME and STREAM_TIME punctuators in Kafka Streams?
Attempts:
2 left
💡 Hint
Think about what each punctuator type uses as its timing source.
✗ Incorrect
WALL_CLOCK_TIME punctuators trigger based on the system clock at fixed intervals regardless of data. STREAM_TIME punctuators trigger only when the stream time (record timestamps) advances.
📝 Syntax
expert2:00remaining
Identify the Syntax Error in Punctuator Scheduling
Which option contains a syntax error in scheduling a punctuator in Kafka Streams?
Attempts:
2 left
💡 Hint
Check the type of the first argument to schedule method.
✗ Incorrect
The schedule method requires a java.time.Duration object as the first argument. Passing an integer like 1000 directly causes a syntax or compilation error.