Bird
0
0

You want to consume messages from multiple topics and process them in order of arrival regardless of topic. Which Consumer API approach should you use?

hard📝 Application Q8 of 15
Kafka - Consumers
You want to consume messages from multiple topics and process them in order of arrival regardless of topic. Which Consumer API approach should you use?
ASubscribe to all topics and poll regularly, processing records as they arrive
BAssign specific partitions manually and poll each separately
CCreate multiple consumers, one per topic, and merge results externally
DUse a producer to reorder messages before consumption
Step-by-Step Solution
Solution:
  1. Step 1: Understand subscription for multiple topics

    subscribe() can take multiple topics, allowing consumer to receive messages from all.
  2. Step 2: Processing order

    poll() returns records in order of arrival across subscribed topics, enabling ordered processing.
  3. Final Answer:

    Subscribe to all topics and poll regularly, processing records as they arrive -> Option A
  4. Quick Check:

    Subscribe multiple topics and poll for ordered processing [OK]
Quick Trick: Subscribe to multiple topics to get combined ordered messages [OK]
Common Mistakes:
  • Assigning partitions manually unnecessarily
  • Using multiple consumers complicates ordering
  • Using producer to reorder is incorrect

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kafka Quizzes