Anton Dolganin

I'm an engineer focused on solving problems, not tied to any specific language. Architecture, development, DevOps — I choose the right tools for the job and build solutions that work in production and scale without pain.

We have two streams: streamA and streamB. We need to join them by key, but not all events exist in both streams.

Join Types Comparison:

Join Type Behavior
Inner Only pairs where the key exists in both
Left All from streamA, plus streamB if present
Outer All pairs from both streams, even if one side is missing

KStream<String, String> streamA = builder.stream("streamA");
KStream<String, String> streamB = builder.stream("streamB");

KStream<String, String> joined = streamA.leftJoin(
    streamB,
    (valueA, valueB) -> valueA + ":" + (valueB == null ? "NO_MATCH" : valueB),
    JoinWindows.of(Duration.ofMinutes(5))
);

joined.to("joined-topic");

What happens: If streamA has a key but streamB doesn’t, it returns valueA:NO_MATCH. If both have the key, it returns the combined value. Outer Join additionally includes records from streamB with no match in streamA.

Real-World Example — Correlating Orders and Payments in an E-commerce System:

  • orders (key: order_id, value: order details)
  • payments (key: order_id, value: payment details)

Inner Join

  • Shows only paid orders.
  • Perfect for analytics.

Left Join

  • Shows all orders, even without payment.
  • Great for CRM and real-time dashboards.

Outer Join

  • Gives a full picture: both unmatched orders and payments.
  • Useful for troubleshooting, investigations, and monitoring failures.

KStream-KStream Outer Join and Left Join — Flexible Stream Correlations in Real Time