The Kafka Streams DSL is built on top of the Streams Processor API. It is the recommended for most users… Most data processing operations can be expressed in just a few lines of DSL code. 10
define arbitrary stream processors that process one received record at a time, and connect these processors with their associated state stores to compose a topology that represents a customized processing logic. 1. KStream & KTable 2. .map() / .filter() 3. .count() / .reduce() / .leftJoin() 4. Direct access to the state stores 15
of the currently processed record • the source kafka topic and partition • Access to the states stores • The abilities to forward records to the down streams A stream processor is a node in the processor topology that represents a single processing step. Processor State Store Input / Output Stream 17
store, where keys and values are arbitrary byte streams. RocksJava is a project to build high performance but easy-to-use Java driver for RocksDB. /tmp/kafka-streams/<application-id> ├── 1_0 ├── 2_0 │ └── VICTORIES-STORE │ └── VICTORIES-STORE:1518220800000 └── global └── rocksdb └── ARENASTATE-STORE-0000000000 <application-id>-ARENAS-STORE-changelog 19 KIP-67: Queryable state for Kafka Streams
"XKE-KSTREAM-PROC-0170b98b-55b6-42b7-93d3-5c3dd734afb4-StreamThread-1" org.apache.kafka.streams.errors.StreamsException: failed to initialize processor PROCESS-ARENA at org.apache.kafka.streams.processor.internals.ProcessorNode.init(ProcessorNode.java:106) at org.apache.kafka.streams.processor.internals.StreamTask.initTopology(StreamTask.java:378) at org.apache.kafka.streams.processor.internals.StreamTask.initializeTopology(StreamTask.java:169) at org.apache.kafka.streams.processor.internals.AssignedTasks.transitionToRunning(AssignedTasks.java:292) at org.apache.kafka.streams.processor.internals.AssignedTasks.initializeNewTasks(AssignedTasks.java:126) at org.apache.kafka.streams.processor.internals.TaskManager.updateNewAndRestoringTasks(TaskManager.java:260) at org.apache.kafka.streams.processor.internals.StreamThread.runOnce(StreamThread.java:813) at org.apache.kafka.streams.processor.internals.StreamThread.runLoop(StreamThread.java:774) at org.apache.kafka.streams.processor.internals.StreamThread.run(StreamThread.java:744) Caused by: org.apache.kafka.streams.errors.TopologyBuilderException: Invalid topology building: Processor PROCESS-ARENA has no access to StateStore ARENA-STORE at org.apache.kafka.streams.processor.internals.ProcessorContextImpl.getStateStore(ProcessorContextImpl.java:72) at fr.xebia.ldi.fighter.stream.processor.ProcessArena.init(ProcessArena.java:23) at org.apache.kafka.streams.processor.internals.ProcessorNode$2.run(ProcessorNode.java:54) at org.apache.kafka.streams.processor.internals.StreamsMetricsImpl.measureLatencyNs(StreamsMetricsImpl.java:208) at org.apache.kafka.streams.processor.internals.ProcessorNode.init(ProcessorNode.java:104) ... 8 more 20
driven by the arrival of messages. Stream time, 10sec 0s 30s 40s Wall clock time, 10sec 0s 40s When wall-clock-time is used, .punctuate() is triggered purely by the wall-clock time. KIP-138: Change punctuate semantics this.context.schedule( 10, PunctuationType.STREAM_TIME, /**/); this.context.schedule( 10, PunctuationType.WALL_CLOCK_TIME, /**/); 22
Photo by Caleb George on Unsplash ◆ Photo by Barn Images on Unsplash ◆ Photo by Rebecca Oliver on Unsplash ◆ Photo by Ian Schneider on Unsplash ➔ The 15 min GIPHY search: ◆ Brent Rambo ◆ The sad boy from Neverland ➔ The 5 min Google image search: ◆ All Character Select Themes from TaciturnArtist ◆ Ryan Hemsworth, the Street Fighter II remix ➔ A bunch of iOS emojis