liveBook · Manning

Kafka Streams

As explained in Kafka for Architects

The Kafka Streams API is the programming interface through which applications define Kafka Streams processing logic.

Suppose one service needs shipping addresses while another needs billing addresses. Kafka brokers do not inspect message content, so putting the routing rule in a producer complicates upstream code, while repeating it in consumers makes each handle irrelevant events. A stream-processing application can instead read the address events and publish each type to its own topic. section 1.5.3

Kafka Streams is a Java library embedded in a standalone application, not a separate processing cluster. The application reads from Kafka topics, applies processing logic, and writes results to Kafka topics. Its API provides a high-level DSL for common operations; KStream represents a continuous event stream, while KTable represents a table-like view updated by incoming events. section 8.1.2 section 8.1.3

Choose the processing model around the work:

  • Use DSL operations to filter, transform, join, or aggregate events. State stores support intermediate results, and windows support time-based aggregations such as hourly order counts. section 8.1.3 section 8.7
  • Use the Processor API when predefined operations do not express the required logic, such as invoking an external anomaly-detection service. Custom processors can work with state stores and explicitly defined topology connections. section 8.3.3

Filtering orders

An orders application reads a raw-orders topic, keeps orders worth at least 50, maps each retained order to a smaller record containing its order and customer IDs, and writes to processed-orders. The application specifies the processing steps rather than manually wiring a consumer to a producer. section 8.1.3

Figure 8.9 Internally, the Kafka Streams application is represented as a graph. Events flow from input topics through source nodes, are processed by processing nodes, and are finally published to output topics via sink nodes.
A screen shot of a black background

Description automatically generated

The topology diagram shows the path from input-topic source nodes through processing nodes to output-topic sink nodes. DSL calls build this graph automatically; the Processor API allows its processors and connections to be specified explicitly. section 8.3.3

Deployment remains an architectural decision. Instances sharing a consumer group divide input partitions; partition counts limit processing parallelism, and failed instances trigger reassignment. Tasks carry partition assignments, topology instances, and any state stores. Kafka Streams supports exactly-once processing and backs stateful operations with changelog topics, but it does not remove the need to plan topics and partitions. section 8.1.2 section 8.3.4 section 8.7

Use streaming when results need to arrive with low latency, such as fraud alerts or a continuously enriched customer view. If daily processing suffices, batch ETL may be simpler and more cost-effective. Kafka Streams is a Java-centered choice; ksqlDB, Apache Flink, and managed services are alternatives to evaluate. section 5.1.4 section 8.0 section 8.7

How Kafka for Architects covers it

How deep it goes
Explains DSL abstractions, custom processors, topologies, tasks, and failure reassignment, without a full implementation walkthrough.
Examples
Uses address routing, order filtering and mapping, fraud detection, and customer-data aggregation as processing scenarios.
What it assumes
Assumes familiarity with Java applications and Kafka topics while defining the stream-processing model and its main abstractions.
What you can do after
Apply it via Kafka Streams to design a Java processing application and plan its topics, partitions, and deployment.
How it connects
Connects Kafka topics and consumer groups to KStream, KTable, state stores, windowed aggregation, and exactly-once processing.

Also explained in

Compare how 3 books explain Kafka Streams →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Kafka for Architects. The section links point to the parts of the book it draws on.