Bird
Raised Fist0

What will happen if you call builder.stream("topic1").filter((k,v) -> v.contains("error")).to("errors"); in a Kafka Streams topology?

medium📝 Predict Output Q5 of Q15
Kafka - Streams
What will happen if you call builder.stream("topic1").filter((k,v) -> v.contains("error")).to("errors"); in a Kafka Streams topology?
AMessages containing 'error' are forwarded to 'errors' topic
BAll messages are sent to 'errors' topic regardless of content
CNo messages are sent because filter syntax is incorrect
DMessages are sent back to 'topic1' after filtering
Step-by-Step Solution
Solution:
  1. Step 1: Understand the filter operation

    Filter passes only messages where value contains "error".
  2. Step 2: Identify the output topic

    Filtered messages are sent to the "errors" topic via to() method.
  3. Final Answer:

    Messages containing 'error' are forwarded to 'errors' topic -> Option A
  4. Quick Check:

    Filter + to() = filtered messages to 'errors' [OK]
Quick Trick: filter() selects messages; to() sends them out [OK]
Common Mistakes:
MISTAKES
  • Assuming filter sends all messages
  • Thinking filter syntax is invalid
  • Confusing output topic with input topic

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kafka Quizzes