Bird
0
0

Given the following code snippet, what will be printed if the punctuator is scheduled with WALL_CLOCK_TIME every 5 seconds?

medium📝 Predict Output Q4 of 15
Kafka - Advanced Stream Processing
Given the following code snippet, what will be printed if the punctuator is scheduled with WALL_CLOCK_TIME every 5 seconds?
context.schedule(Duration.ofSeconds(5), PunctuationType.WALL_CLOCK_TIME, timestamp -> System.out.println("Tick at " + timestamp));
APrints 'Tick at' with the current system time every 5 seconds.
BPrints 'Tick at' with the stream record timestamp every 5 seconds.
CPrints 'Tick at' once immediately and never again.
DThrows a runtime exception due to invalid scheduling.
Step-by-Step Solution
Solution:
  1. Step 1: Understand WALL_CLOCK_TIME punctuator behavior

    WALL_CLOCK_TIME triggers punctuators based on system clock time intervals.
  2. Step 2: Analyze the output of the lambda

    The lambda prints the timestamp passed, which for WALL_CLOCK_TIME is the current system time.
  3. Final Answer:

    Prints 'Tick at' with the current system time every 5 seconds. -> Option A
  4. Quick Check:

    WALL_CLOCK_TIME = system time ticks [OK]
Quick Trick: WALL_CLOCK_TIME uses system time, STREAM_TIME uses record time [OK]
Common Mistakes:
  • Confusing WALL_CLOCK_TIME with STREAM_TIME
  • Expecting immediate single print
  • Assuming scheduling causes errors

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kafka Quizzes