liveBook · Manning

Join

As explained in Kafka for Architects

A stream join is a stream-processing operation that combines records from multiple streams or tables when their keys or other join conditions match.

A stream join combines related records from multiple streams or tables when their keys or other conditions match. It supports event enrichment, such as producing a more complete object from an order and its payment. section 8.3.6

Architecturally, a join can move enrichment and aggregation out of a final Kafka consumer into an intermediate streaming service. The service publishes a reusable aggregated result, while downstream services read prepared data. section 8.0

Design a join around these constraints:

  • Match records with an explicit condition, such as order.id = payment.order_id. section 8.3.6
  • Use the same number of partitions for every input topic. section 8.3.6
  • Use the same key distribution strategy and partitioning logic so matching records reach corresponding partitions. section 8.3.6
  • Treat key alignment as application responsibility because Kafka Streams does not validate or enforce it at runtime. section 8.3.6

Orders and payments

An order keyed by orderId can join a payment when the payment topic is repartitioned with the same orderId key. Partitions with the same index are assigned to the same processing task, allowing corresponding records to be processed together. The design must also account for orders and payments arriving at different times or in either order. section 8.3.6

Figure 8.13 Partitions with the same index are assigned to the same task, and this assignment remains fixed. Elements in input topics that arrive in partitions with the same index will be processed together.
A group of rectangular white rectangular objects with black text

Description automatically generated

Use the partition-assignment diagram to see why equal partition indexes bring records from joined topics to the same Kafka Streams task. section 8.3.6

How Kafka for Architects covers it

How deep it goes
Explains matching, copartitioning, task assignment, and arrival-order challenges, but does not provide implementation code.
Examples
Uses order-payment enrichment and Customer 360 joins between transactions and customer profiles.
What it assumes
Assumes familiarity with Kafka topics, keys, partitions, partitioners, and stream-processing transformations.
What you can do after
Evaluate join designs by checking match conditions, partition alignment, key distribution, and downstream aggregation needs.
How it connects
Connects joins with event enrichment, aggregation, Kafka Streams, partitioning, copartitioning, and stream processing.

Also explained in

Compare how 16 books explain join →

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.