Skip to Content

When is a queue (RabbitMQ / SQS) better than a pub/sub (Kafka)?

Category: System Design

Answer

Queues are point-to-point: one consumer gets each message. Pub/sub is fan-out: every subscriber gets a copy. Use a queue for tasks (PDF processing, email sending) where exactly one worker should do the work. Use pub/sub for events (audit logs, change data capture) where many systems care.

Concrete examples from the fca project context

Example 1

Queue: SQS / RabbitMQ — each message delivered to one worker.

Example 2

Pub/sub: Kafka / Redis Streams / SNS — each message broadcast to many subscribers.

Example 3

You can combine: publish a “pdf.submitted” event so analytics and indexer both react, while a queue handles actual processing.

Data flow / flow chart

producer -> [queue] -> ONE consumer (work)
producer -> [topic]  -> MANY subscribers (events)

Takeaway

Tasks = queue. Events = pub/sub. They are different shapes of plumbing.