Overview
The stream-processor service is a pure Kafka Streams application (no Spring Boot) that joins factory floor MES events with production line configuration, maintains running shift aggregates per line, and emits snapshots downstream whenever meaningful changes occur.
Key Behaviors
- KStream-KTable join: MES events are enriched with line configuration (factory, operation area, process line) via a left join on
lineId - Event-driven shift windows: Shift boundaries are determined by SHIFT_STARTED and SHIFT_ENDED events, not time-based tumbling windows
- Change detection filter: Only emits a ShiftAggregate when scrap count changes or scrap rate changes by ≥0.5%, preventing downstream flooding
- Exactly-once semantics: Configured with
processing.guarantee=exactly_once_v2
State Store
| Store | Type | Key | Value |
|---|---|---|---|
shift-aggregates-store | KeyValueStore | lineId (String) | ShiftAggregate |
Data Simulator
The DataSimulator CLI tool is included in this module for local development. It generates realistic MES events across 3 production lines, including a scrap spike scenario on LINE-1.
mvn exec:java -pl stream-processor \ -Dexec.mainClass=com.kstreamalarm.processor.simulator.DataSimulator