liveBook · Manning

PunctuationType.WALL_CLOCK_TIME

As explained in Kafka Streams in Action, Second Edition

PunctuationType.WALL_CLOCK_TIME is a Kafka Streams scheduling mode that triggers punctuation according to the system clock of the Kafka Streams environment.

PunctuationType.WALL_CLOCK_TIME schedules a Punctuator using the Kafka Streams environment’s system clock rather than timestamps extracted from records. It suits periodic work that should continue even when event flow is sporadic. section 10.2.1 section 10.2.2

Use wall-clock punctuation when:

  • The application must perform activity regularly regardless of data flow. section 10.2.2
  • A processor schedules its Punctuator through ProcessorContext.schedule(Duration, PunctuationType, Punctuator). section 10.2.1
  • Timing can be approximate: wall-clock progress is observed during polling, and precision depends on polling-cycle duration. section 10.2.2

Stock-performance processor

A stock-performance processor can schedule its punctuator for a ten-second interval with WALL_CLOCK_TIME. The processor can then examine accumulated stock data approximately every ten seconds, even when trades arrive irregularly. By contrast, STREAM_TIME waits for extracted timestamps to advance. section 10.2.1 section 10.2.2

Listing 10.5 Stock-performance application with a custom processor
Topology topology = new Topology();
 String stocksStateStore = "stock-performance-store";
 double differentialThreshold = 0.02;            #1

KeyValueBytesStoreSupplier storeSupplier =
 Stores.inMemoryKeyValueStore(stocksStateStore);    #2
StoreBuilder<KeyValueStore<String, StockPerformance>> storeBuilder
 = Stores.keyValueStoreBuilder(
 storeSupplier, Serdes.String(), stockPerformanceSerde);    #3


  topology.addSource("stocks-source",
                    stringDeserializer,
                    stockTransactionDeserializer,
                    "stock-transactions")
          .addProcessor("stocks-processor",    #4
                    new StockPerformanceProcessorSupplier(storeBuilder),
                    "stocks-source")
          .addSink("stocks-sink",
                   "stock-performance",
                   stringSerializer,
                   stockPerformanceSerializer,
                   "stocks-processor");        #5

Inspect the custom stock processor topology to see the source, state store, processor, and sink that provide the surrounding implementation context for scheduling. section 10.2.1

How Kafka Streams in Action, Second Edition covers it

How deep it goes
Explains scheduling behavior, polling-based granularity, and stream-time contrast, but stops short of a dedicated WALL_CLOCK_TIME code listing.
Examples
Uses a stock-performance processor scheduled at ten-second intervals and contrasts it with timestamp-driven punctuation.
What it assumes
Assumes familiarity with processors, Punctuator callbacks, ProcessorContext scheduling, and record timestamps.
What you can do after
Apply it via the Processor API when periodic processing must continue regardless of data activity.
How it connects
Connects Punctuator, ProcessorContext, TimestampExtractor, stream-time semantics, and polling intervals.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Kafka Streams in Action, Second Edition. The section links point to the parts of the book it draws on.