What is the difference between a message queue and publish-subscribe?
In a queue each message is processed by exactly one consumer from a group, which shares the work. In pub-sub each message is delivered to every subscriber, so many services can react to the same event.
Explain it simply
A queue is a ticket counter line: each customer is served by one clerk, and clerks share the line. Pub-sub is a college notice board or a WhatsApp group: one post, everybody subscribed sees it.
Queue (point to point): producers add jobs; several workers pull from the same queue; each job goes to one worker. Use it to distribute work, such as resizing uploaded images or sending emails.
Pub-sub (fan-out): a publisher sends an event to a topic; each subscriber gets its own copy. Use it to notify several systems about one fact, such as "order placed" going to billing, inventory and notifications.
Real systems blend them. Kafka uses consumer groups: within a group, partitions are divided like a queue; across groups, every group receives everything like pub-sub. SNS plus SQS is another combination: publish to a topic, and each subscriber has its own queue.
Example
Event: order 981 placed.
Queue "invoice-jobs": 3 workers -> order 981 handled by ONE worker.
Topic "order-placed": billing, inventory, email each get order 981.What to say in the interview
"A queue distributes each message to one consumer for load sharing; pub-sub broadcasts each message to all subscribers for decoupled reactions. Kafka and SNS with SQS combine both, using consumer groups or per-subscriber queues."