liveBook · Manning

Kafka Streams

As explained in Kafka Streams in Action, Second Edition

The Kafka Streams API is the programming interface for building stream-processing applications with Kafka Streams.

Kafka Streams is Kafka’s native Java stream-processing library for client applications. It runs outside Kafka brokers, connects to a Kafka cluster, and lets applications transform event records, including with stateful operations such as joins and aggregations. section 1.4.5 section 1.6

A Kafka Streams application is a processing topology: a graph whose source nodes read topic records, processing nodes transform key-value records, and sink nodes write results to Kafka topics. The API abstracts over Kafka producers and consumers so the application can focus on stream-processing requirements. section 6.0 section 6.1

Figure 6.1 Kafka Streams is a graph with a source node, any number of processing nodes, and a sink node.
figure

Use the topology diagram to identify the minimum source-to-sink flow and where additional processing nodes fit. section 6.1

A typical application is assembled in this order:

  • Set required application.id and bootstrap.servers properties. The application ID identifies the logical application; bootstrap servers establish the cluster connection. section 6.3.2
  • Create Serdes for record serialization and deserialization, then build the processor topology. section 6.3
  • Create and start Kafka Streams. Applications sharing an application.id are treated as one logical application. section 6.3 section 6.7
  • Transform, select, split, merge, or inspect records with operations such as mapValues, map, filter, branch, merge, selectKey, peek, and print. section 6.7

From incoming text to retail decisions

The minimal Yelling app reads text, converts values to uppercase, and writes them to an output topic. A more realistic retail topology masks purchase-card digits, emits purchase and regional data to topics, and supplies reward data for downstream consumers. Another real-time application builds location-based purchase trends and writes them to a sales-trends topic for dashboard export. section 6.3 section 6.4 section 1.5

Spring Boot can manage a Kafka Streams application with @EnableKafkaStreams. It creates lifecycle support around KafkaStreams; configuration supplies the streams settings, while a StreamsBuilder defines the topology. Customizers can attach a state listener, and explicit startup and shutdown can be handled with KafkaStreams.start and close. section 12.3

How Kafka Streams in Action, Second Edition covers it

How deep it goes
Works through topology construction, required configuration, Serdes, common KStream operations, and Spring lifecycle integration.
Examples
Uses an uppercase-message topology, ZMart purchase masking and rewards routing, sales-trend processing, and loan-approval aggregation.
What it assumes
Assumes familiarity with Kafka producers and consumers while briefly positioning Streams as their abstraction.
What you can do after
Build it from scratch by configuring a Java topology, transforming topic records, and starting a Kafka Streams application.
How it connects
Connects Kafka Streams to Kafka brokers, producers, consumers, topics, Serdes, joins, aggregations, Spring Boot, and Kafka Connect.

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 Streams in Action, Second Edition. The section links point to the parts of the book it draws on.