A stream topology is a directed graph that defines the flow of data through various processing steps in a Kafka Streams application. It shows how streams and tables are connected and processed.
Click to reveal answer
beginner
Name the main components of a Kafka Streams topology.
The main components are:
Source nodes (where data enters)
Processor nodes (where data is processed)
Sink nodes (where data is sent out)
Click to reveal answer
intermediate
How do you build a stream topology in Kafka Streams?
You use the <code>StreamsBuilder</code> class to define sources, processors, and sinks, then call <code>build()</code> to create the topology.
Click to reveal answer
intermediate
What is the role of a Processor API in stream topology?
The Processor API lets you define custom processing logic by creating processor nodes that can transform, filter, or join streams within the topology.
Click to reveal answer
beginner
Explain the difference between source and sink nodes in a stream topology.
Source nodes read data from Kafka topics into the topology. Sink nodes write processed data back to Kafka topics or external systems.
Click to reveal answer
Which Kafka Streams class is used to build a stream topology?
AKafkaProducer
BStreamsBuilder
CKafkaConsumer
DTopologyBuilder
✗ Incorrect
StreamsBuilder is the class used to define sources, processors, and sinks to build a stream topology.
In a stream topology, what does a sink node do?
AWrites data to Kafka topics or external systems
BProcesses data inside the topology
CStores data in memory
DReads data from Kafka topics
✗ Incorrect
Sink nodes write processed data out to Kafka topics or external systems.
What is the purpose of processor nodes in a Kafka Streams topology?
ATo write data to external databases
BTo read data from Kafka topics
CTo apply custom processing logic on streams
DTo monitor Kafka cluster health
✗ Incorrect
Processor nodes apply custom logic like filtering, transforming, or joining streams.
Which of the following best describes a stream topology?
AA list of Kafka topics
BA configuration file for Kafka brokers
CA database schema
DA graph showing data flow and processing steps
✗ Incorrect
A stream topology is a directed graph showing how data flows and is processed.
How do you finalize the definition of a stream topology in Kafka Streams?
ACall <code>build()</code> on StreamsBuilder
BCall <code>start()</code> on StreamsBuilder
CCall <code>connect()</code> on KafkaConsumer
DCall <code>send()</code> on KafkaProducer
✗ Incorrect
Calling build() on StreamsBuilder creates the topology object.
Describe the components of a Kafka Streams topology and their roles.
Think about where data enters, how it is processed, and where it goes out.
You got /4 concepts.
Explain how you would create and build a stream topology using Kafka Streams API.
Focus on the steps from starting with StreamsBuilder to getting the topology object.
You got /5 concepts.
Practice
(1/5)
1. What does a Kafka Streams topology represent?
easy
A. The configuration settings for Kafka brokers
B. The flow and processing steps of data in a Kafka Streams application
C. The list of Kafka topics available in the cluster
D. The schema of messages in a Kafka topic
Solution
Step 1: Understand the role of topology in Kafka Streams
A topology defines how data flows and is processed in a Kafka Streams app.
Step 2: Differentiate topology from other Kafka concepts
It is not about broker configs, topic lists, or message schemas, but about processing steps.
Final Answer:
The flow and processing steps of data in a Kafka Streams application -> Option B
Quick Check:
Topology = Data flow and processing [OK]
Hint: Topology means data flow and processing steps [OK]
Common Mistakes:
Confusing topology with Kafka broker settings
Thinking topology lists topics
Assuming topology defines message schema
2. Which code snippet correctly builds a Kafka Streams topology?
easy
A. StreamsBuilder builder = new StreamsBuilder(); builder.run();
B. StreamsBuilder builder = new StreamsBuilder(); builder.start();
C. StreamsBuilder builder = new StreamsBuilder(); builder.create();
D. StreamsBuilder builder = new StreamsBuilder(); builder.build();
Solution
Step 1: Recall the correct method to build topology
The method to finalize and get the topology is build().
Step 2: Check each option's method
Only StreamsBuilder builder = new StreamsBuilder(); builder.build(); uses build(), others use invalid methods.
Final Answer:
StreamsBuilder builder = new StreamsBuilder(); builder.build(); -> Option D
Quick Check:
Use build() to create topology [OK]
Hint: Use build() method on StreamsBuilder to create topology [OK]
Common Mistakes:
Using start(), create(), or run() instead of build()
Confusing topology building with starting the stream
A. The filtered stream is not sent to any sink topic, so no output node is created
B. The filter method is invalid and causes a syntax error
C. StreamsBuilder cannot build topology without a source topic
D. Calling build() before defining streams causes runtime error
Solution
Step 1: Check the stream processing chain
The code filters the stream but does not write the result to any output topic.
Step 2: Understand topology implications
Without a sink node, the topology has no output, which is usually an error or incomplete.
Final Answer:
The filtered stream is not sent to any sink topic, so no output node is created -> Option A
Quick Check:
Missing sink node causes incomplete topology [OK]
Hint: Always send processed stream to sink topic [OK]
Common Mistakes:
Assuming filter causes syntax error
Thinking build() requires no streams
Ignoring missing sink topic after processing
5. You want to create a Kafka Streams topology that reads from two topics, merges their streams, filters messages containing 'error', and writes to an output topic. Which code snippet correctly builds this topology?