group.id decides queue vs pub/sub
Two delivery contracts, one log
The classic messaging dichotomy:
- Queue (competing consumers) — each message is delivered to exactly one of N workers. Used to share load. Think RabbitMQ work queue, SQS.
- Pub/Sub (fan-out) — each message is delivered to every interested subscriber independently. Used to broadcast facts. Think SNS, a topic exchange.
Kafka unifies both with one primitive: the consumer group.
- Put all your workers in the same group → the partitions are split among them → queue semantics (each record handled once by the group).
- Give each independent service its own group on the same topic → every group reads every record → pub/sub semantics (fan-out).
So 'queue vs topic' isn't a Kafka deployment choice — it's a group.id choice made
per consumer. The log is retained either way, which is the superpower legacy brokers
lack: a new subscriber can join tomorrow and replay everything from offset 0.