Bird
Raised Fist0

Given the code snippet:

medium📝 Predict Output Q13 of Q15
Kafka - Streams
Given the code snippet:
StreamsBuilder builder = new StreamsBuilder();
builder.stream("input-topic").mapValues(value -> value.toUpperCase()).to("output-topic");
Topology topology = builder.build();
System.out.println(topology.describe());

What will the printed topology description include?
AA sink node for 'input-topic' and a source node for 'output-topic'
BOnly a source node for 'input-topic' without any processing
CA source node for 'input-topic', a processor node for mapValues, and a sink node for 'output-topic'
DAn error because mapValues is not allowed in topology
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the stream processing steps

    The code reads from 'input-topic', applies mapValues to uppercase, then writes to 'output-topic'.
  2. Step 2: Understand topology description output

    The description shows source nodes (input), processor nodes (mapValues), and sink nodes (output).
  3. Final Answer:

    A source node for 'input-topic', a processor node for mapValues, and a sink node for 'output-topic' -> Option C
  4. Quick Check:

    Topology describe shows source, processor, sink [OK]
Quick Trick: Topology describe shows source, processor, and sink nodes [OK]
Common Mistakes:
MISTAKES
  • Thinking mapValues is not part of topology
  • Confusing source and sink nodes
  • Expecting no processor nodes in description

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kafka Quizzes