Bird
0
0

Given this code snippet using TopologyTestDriver to process a record:

medium📝 Predict Output Q4 of 15
Kafka - Advanced Stream Processing
Given this code snippet using TopologyTestDriver to process a record:
var driver = new TopologyTestDriver(topology, props);
var inputTopic = driver.createInputTopic("input", new StringSerializer(), new StringSerializer());
inputTopic.pipeInput("key1", "value1");
var outputTopic = driver.createOutputTopic("output", new StringDeserializer(), new StringDeserializer());
var result = outputTopic.readKeyValue();
System.out.println(result.key + ":" + result.value);

What will be printed if the topology forwards input to output unchanged?
Akey1:value1
Bvalue1:key1
Cnull:null
DException thrown at runtime
Step-by-Step Solution
Solution:
  1. Step 1: Understand the data flow in the test

    The input topic receives key "key1" and value "value1"; the topology forwards it unchanged to output topic.
  2. Step 2: Read output and print

    Reading from output topic returns the same key-value pair; printing concatenates as "key1:value1".
  3. Final Answer:

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

    Forwarded key-value output = C [OK]
Quick Trick: Output matches input if topology forwards unchanged [OK]
Common Mistakes:
  • Swapping key and value in output
  • Expecting null if no processing
  • Assuming runtime exceptions without errors

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kafka Quizzes