0
0
Kafkadevops~20 mins

Punctuators for time-based triggers in Kafka - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Kafka Punctuator Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2: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() {}
  });
AInfinite lines printed continuously without delay
BThree lines printed with timestamps approximately 1000ms apart
CNo output printed because punctuator is never triggered
DOne line printed with the timestamp at start
Attempts:
2 left
💡 Hint
Think about how often the punctuator is scheduled and how long the stream runs.
Predict Output
intermediate
2: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);
});
ATriggers once at the start and never again
BTriggers every 500ms wall-clock time regardless of stream time
CTriggers continuously without waiting for stream time advancement
DTriggers only when stream time advances by 500ms, printing timestamps accordingly
Attempts:
2 left
💡 Hint
STREAM_TIME punctuators depend on the progress of stream time, not wall-clock time.
🔧 Debug
advanced
2: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);
});
ABecause no records with advancing timestamps are processed, so stream time never advances
BBecause the schedule method is called outside the init method
CBecause Duration.ofMillis(1000) is invalid for STREAM_TIME punctuators
DBecause PunctuationType.STREAM_TIME punctuators require manual triggering
Attempts:
2 left
💡 Hint
STREAM_TIME punctuators depend on stream time advancing.
🧠 Conceptual
advanced
2: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?
AWALL_CLOCK_TIME triggers only when records arrive; STREAM_TIME triggers on system clock
BWALL_CLOCK_TIME triggers only once; STREAM_TIME triggers repeatedly at fixed intervals
CWALL_CLOCK_TIME triggers based on real time intervals; STREAM_TIME triggers based on record timestamps advancing
DWALL_CLOCK_TIME triggers based on record timestamps; STREAM_TIME triggers based on processing time
Attempts:
2 left
💡 Hint
Think about what each punctuator type uses as its timing source.
📝 Syntax
expert
2:00remaining
Identify the Syntax Error in Punctuator Scheduling
Which option contains a syntax error in scheduling a punctuator in Kafka Streams?
Acontext.schedule(1000, PunctuationType.WALL_CLOCK_TIME, timestamp -> System.out.println(timestamp));
Bcontext.schedule(Duration.ofMillis(500), PunctuationType.STREAM_TIME, (timestamp) -> { System.out.println(timestamp); });
Ccontext.schedule(Duration.ofSeconds(1), PunctuationType.WALL_CLOCK_TIME, timestamp -> System.out.println(timestamp));
Dcontext.schedule(Duration.ofMinutes(1), PunctuationType.STREAM_TIME, timestamp -> System.out.println(timestamp));
Attempts:
2 left
💡 Hint
Check the type of the first argument to schedule method.