liveBook · Manning

Default branch

As explained in Kafka Streams in Action, Second Edition

A default branch is a fallback stream branch that receives records matching none of the specified predicates.

A default branch is the fallback path in a split Kafka Streams topology. It receives every record that fails to match the configured branch predicates. section 6.6.2

Build the branching flow by:

  • Calling KStream.split() to obtain a BranchedKStream. section 6.6.2
  • Adding branch() calls whose predicates route matching records to branch processors. section 6.6.2
  • Calling defaultBranch() to retain unmatched records, or noDefaultBranch() to drop them. section 6.6.2
  • Keeping the same key and value types across every branch. section 6.6.2

Retail purchase routing

After routing coffee purchases to coffee-topic and electronics purchases to electronics, send the default branch to purchases. That stream handles every other department. section 6.6.2

How Kafka Streams in Action, Second Edition covers it

How deep it goes
Explains the split, predicate, branch, and termination APIs, stopping short of advanced branching options.
Examples
Uses coffee, electronics, and other retail purchases to demonstrate specific branches and a purchases fallback topic.
What it assumes
Assumes basic KStream and predicate familiarity while defining the branching sequence and fallback behavior.
What you can do after
Apply it via Kafka Streams to preserve or deliberately discard records that match no branch predicate.
How it connects
Connects default branches with KStream, BranchedKStream, predicates, stream splitting, and stream merging.

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.