All Projects
Backend
Real-Time Event Streaming — Kafka + Spring Cloud Stream
Functional event-stream processing with Spring Cloud Stream and Kafka Streams: a supplier produces page events, a function transforms them, and a KStream pipeline applies 5-second sliding windows for real-time per-page analytics streamed to the browser via Server-Sent Events.
Kafka Streams
Streaming engine
5s sliding
Window size
SSE
Live transport
4
Functional beans
Approach
Functional supplier/function/consumer beans + windowed KStream aggregation streamed live over SSE
Tech Stack
Java 17Spring Boot 3.3Spring Cloud StreamApache KafkaKafka StreamsDocker Compose
Keywords
Apache KafkaKafka StreamsSpring Cloud StreamEvent-DrivenSSEDockerWindowing
Deep Dive
An event-driven pipeline built around the functional programming model of Spring Cloud Stream, with stateful Kafka Streams aggregations.
Pipeline
pageEvent1Supplier ──► topic R2 ──► pageEvent1Consumer (logs)
└─► pageEvent1Function (transform)
StreamBridge
GET /publish/{topic}/{name} ─────► topic
│
KStream1Function: filter ──► 5s sliding window ──► count by page ──► topic R4
│
GET /analytics ◄── Server-Sent Events ◄── interactive query (state store)
Functional beans
| Bean | Type | Job |
|---|---|---|
pageEvent1Supplier | Supplier | Emits PageEvent1 to topic R2 continuously |
pageEvent1Consumer | Consumer | Consumes & displays events |
pageEvent1Function | Function | Transforms events |
KStream1Function | KStream | Filters, windows (5s), counts by page → R4 |
Highlights
- ▸Stateful windowed aggregation with interactive queries over the state store
- ▸Real-time analytics pushed to the UI via Server-Sent Events
- ▸Kafka brokers spun up with Docker Compose for one-command local dev