intermediate

Topic

Use topics for named event streams or publish-subscribe channels where multiple independent consumers can receive related messages.

Topics name a stream or channel where publishers emit messages and multiple subscribers can receive copies — pub/sub semantics. In Kafka, a topic is a durable partitioned log; in RabbitMQ, topic exchanges route by routing keys.

Trade-off: fan-out flexibility versus consumer coordination and retention management.

On interviews: model OrderPlaced as topic with inventory, billing, and analytics subscribers; partition key choice.

Common pitfalls: one topic for unrelated events; subscribers without consumer groups competing incorrectly; no retention policy.

Checklist:

  • Name topics by domain event or bounded context.
  • Document producers, schemas, and subscribers.
  • Choose partitioning for scale and ordering needs.
  • Set retention aligned with replay requirements.