Bird
0
0

You have this Kafka CQRS code snippet:

medium📝 Debug Q14 of 15
Kafka - Event-Driven Architecture
You have this Kafka CQRS code snippet:
producer.send('commands', 'CreateOrder')
consumer.subscribe(['commands', 'events'])

What is the main problem here?
AConsumer should not subscribe to both 'commands' and 'events' topics
BProducer should send to 'events' topic, not 'commands'
CProducer must send JSON, not strings
DConsumer must subscribe only to 'commands' topic
Step-by-Step Solution
Solution:
  1. Step 1: Understand CQRS topic roles

    Commands topic is for writes; events topic is for read updates. Consumers usually subscribe to one role.
  2. Step 2: Analyze consumer subscription

    Subscribing to both commands and events mixes responsibilities and can cause confusion or errors.
  3. Final Answer:

    Consumer should not subscribe to both 'commands' and 'events' topics -> Option A
  4. Quick Check:

    Consumer subscribes to one topic type only [OK]
Quick Trick: Consumers should subscribe to either commands or events, not both [OK]
Common Mistakes:
MISTAKES
  • Thinking producer must send events on commands topic
  • Assuming consumer can handle both topics safely
  • Ignoring message format requirements

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kafka Quizzes