Kafka Streams: A KStream is a record stream, a KTable is a changelog

The same topic read as a table keeps only the latest value per key.

Code
StreamsBuilder builder = new StreamsBuilder();

KStream<String, Order> orders = builder.stream("orders");
KTable<String, Customer> customers = builder.table("customers");

orders.join(customers, (order, customer) -> enrich(order, customer))
      .to("orders-enriched");
Output
KStream: every event, including three updates to the same key
KTable:  one row per key, updated in place
Advertisement

Run this yourself in the Online Java Compiler, spin up a live REST API in the API Sandbox, or practise with Java interview questions.

Published 2026-08-11