Apache Kafka Kafka Streams 1 — Questions and Answers
Question 1: What type of library is Kafka Streams?
- A client-side Java library for stream processing, requiring no separate cluster (Correct answer)
- A distributed processing engine like Apache Flink
- A REST API layer on top of Kafka
- A separate server component bundled with Kafka
Correct answer: A client-side Java library for stream processing, requiring no separate cluster
Kafka Streams is a lightweight Java library embedded in your application — it uses Kafka topics as input/output and needs no additional infrastructure.
Question 2: What is a KStream in Kafka Streams?
- An unbounded sequence of individual key-value records (changelog stream) (Correct answer)
- A materialized table of the latest value per key
- A windowed aggregation result
- A batch of compressed messages
Correct answer: An unbounded sequence of individual key-value records (changelog stream)
A KStream represents a continuous, unbounded stream of key-value records where each record is an independent event.
Question 3: What is a KTable in Kafka Streams?
- A changelog stream interpreted as a table where each record is an upsert by key (Correct answer)
- A static lookup table loaded from a file
- A batched write buffer
- An in-memory cache of recent messages
Correct answer: A changelog stream interpreted as a table where each record is an upsert by key
A KTable models a mutable table backed by a changelog topic; each new record with an existing key updates (upserts) the current value for that key.
Question 4: Which method is used to materialize a KTable into a queryable local state store?
- Materialized.as() (Correct answer)
- toStream()
- groupByKey()
- through()
Correct answer: Materialized.as()
Materialized.as() specifies a named state store backed by RocksDB where the KTable's data is accessible for interactive queries.
Question 5: What is the default state store backend used by Kafka Streams for persistent state?
- RocksDB (Correct answer)
- LevelDB
- H2 in-process database
- Apache Cassandra
Correct answer: RocksDB
Kafka Streams uses RocksDB as its default embedded persistent key-value store for local state in aggregations and joins.
Question 6: What does a 'stream-table join' in Kafka Streams do?
- Enriches each stream record with the current table value for the matching key (Correct answer)
- Merges two streams by timestamp
- Aggregates stream records into table format
- Joins two tables producing a new table
Correct answer: Enriches each stream record with the current table value for the matching key
A stream-table join looks up the latest KTable value for a record's key and enriches the stream record with that value in real time.
What type of library is Kafka Streams?