liveBook · Manning

Merge

As explained in Apache Kafka in Action

merge is a stream-processing function that combines records from multiple streams into one stream.

When sales events arrive from several branches, merge() combines uniform streams into one stream for continued processing. Its behavior resembles SQL UNION: elements from both inputs enter the resulting stream. section 12.2.1

Combine branch sales streams

salesDataNorth.merge(salesDataSouth) creates one stream containing sales data from the northern and southern branches, suitable for downstream processing in a central Kafka environment. section 12.2.1

salesDataNorth.merge(salesDataSouth)

Inspect the concise processor expression that merges the northern and southern sales streams. section 12.2.1

Use merge alongside related stream processors:

  • Use filter() to select records, map() to transform them, and merge() to combine compatible streams. section 12.2.1
  • Choose joins when combining streams or tables through database-style relationships rather than simply appending uniform inputs. section 12.2.1
  • Choose split() when one stream must branch into multiple condition-based outputs instead of becoming a single combined stream. section 12.2.1

How Apache Kafka in Action covers it

How deep it goes
Explains the processor’s input combination, SQL UNION analogy, and branch-sales example without detailing execution internals.
Examples
Uses northern and southern branch sales streams merged into a central processing flow.
What it assumes
Assumes existing data streams and basic stream processors, while presenting merge() within real-time stream-processing workflows.
What you can do after
Apply it via Kafka Streams-style processor expressions to combine compatible streams for downstream analysis or processing.
How it connects
Connects merge() with stream processing, Kafka Streams, filter(), map(), joins, split(), and processor topologies.

Also explained in

Compare how 5 books explain merge →

Related concepts

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