Bird
0
0

Given the following code snippet using TopologyTestDriver:

medium📝 Predict Output Q13 of 15
Kafka - Advanced Stream Processing
Given the following code snippet using TopologyTestDriver:
var driver = new TopologyTestDriver(topology, props);
var inputTopic = driver.createInputTopic("input", Serdes.String().serializer(), Serdes.String().serializer());
var outputTopic = driver.createOutputTopic("output", Serdes.String().deserializer(), Serdes.String().deserializer());

inputTopic.pipeInput("key1", "value1");
var result = outputTopic.readKeyValue();
System.out.println(result.key + ":" + result.value);
What will be printed if the topology simply forwards input to output unchanged?
Akey1:value1
Bnull:null
Cvalue1:key1
DException thrown
Step-by-Step Solution
Solution:
  1. Step 1: Understand the topology behavior

    The topology forwards input key-value pairs unchanged to the output topic.
  2. Step 2: Trace the test driver code

    Input "key1" and "value1" is piped in; outputTopic reads the same key-value pair.
  3. Final Answer:

    key1:value1 -> Option A
  4. Quick Check:

    Forwarded key-value = key1:value1 [OK]
Quick Trick: If topology forwards, output matches input exactly [OK]
Common Mistakes:
MISTAKES
  • Mixing key and value order
  • Expecting null output without input
  • Assuming exceptions without errors

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kafka Quizzes