← Back to Message queues vs event streams
🧥 Message queues vs event streams: cheat sheet
🎨 The analogyA coat-check pile, where each ticket is handled once, versus a guestbook anyone can reread from any page.
🎓 The regular explanationTwo shapes of messaging. A queue hands each message to one of several competing consumers and deletes it once acknowledged; an event stream is a retained, append-only log that any number of consumer groups read at their own offsets and can replay.
- The clerk writes three jobs on tickets and pins them on the coat-check pile, then gets back to the desk.
- Mia takes ticket 1 and Leo takes ticket 2 at the same time. Each ticket goes to just one of them, so they don't chase the same coat.
- Leo's job is quick. He brings coat 2 back and tears ticket 2 up, while Mia is still looking for coat 1. Job 2 finished before job 1.
- Leo takes ticket 3 straight away. Mia finally finds coat 1 and tears ticket 1 up.
- Leo finishes job 3 and tears up the last ticket. Every job was done once, by one attendant, and the pile keeps no record of them.
- Four visitors arrive, and each writes one line on the next empty line of the guestbook.
- The café manager reads three lines and moves a bookmark. The gift shop reads one line with its own bookmark. Reading takes nothing out of the book.
- Another visitor signs. The gift shop catches up at its own speed, and the café hasn't read the new line yet. Neither waits for the other.
- A new curator starts work. Instead of only seeing new visitors, the curator opens the guestbook at the very first line.
- The curator reads every line, right up to the newest one. Everything that happened is still there to read.
- Mia takes the next ticket. It's off the pile, so nobody else takes the same job, but it isn't torn up yet.
- Mia trips and is out of action. Nobody tore the ticket up, so after a few minutes it goes back on the pile. If Mia had already fetched the coat, it gets fetched twice.
- Leo takes it, but the number is smudged and the coat can't be found. He puts it back, and the same thing happens again. The desk counts every try.
- Three tries is the limit, so the smudged ticket goes into the problem tray, out of everyone's way.
- The other jobs keep moving. Leo does ticket 5 and tears it up, and Mia is back on her feet.
- Later the manager looks in the problem tray, works out what went wrong and can put the ticket back on the pile.
- Ana signs twice, so both her lines go in the A to H book, in the order she wrote them. Lee and Sam sign in their own books.
- The café team shares the books out. Cara reads two books and Cole reads one, and each book has just one reader, so its lines are read in order.
- Cleo joins the team and takes over the I to P book. Now three readers work at the same time.
- Cruz joins too, but there are only three books. With every book already taken, Cruz has nothing to read.
- Ana arrives. The front desk hands one note about her to the copy clerk.
- The clerk pins a copy on every team's pile, one for the coat-check and one for the café.
- Each team takes its own copy, does its job and tears that copy up. Neither one touches the other's pile.
- The gift shop starts helping too, so the clerk adds a pile for it. But the pile starts empty. Ana's visit is gone for good.
- Ben arrives, and now the clerk pins three copies. Every new team means another pile and another copy of every ticket.
- Ana arrives. The desk pins a ticket for the job (hang up her coat) and writes the fact (Ana came) in the guestbook, under two earlier visitors.
- Mia hangs up the coat once and tears up the ticket. That job is done and nobody needs it again.
- The café manager and the curator each read the guestbook to keep their own lists up to date, each with their own bookmark.
- The curator finds the tally was wrong, so moves the bookmark back to the very first line to count again.
- The curator reads every line again and the tally is right this time. Only the guestbook could do that; the torn-up tickets are gone.
🧩 Key questions
- Mia and Leo both work the coat-check pile. Mia takes a ticket. Can Leo get the same ticket while she has it?
- No, unless Mia never finishes it; then it goes back on the pile for someone else. Each ticket goes to one attendant, but it's only torn up once the job is done, so a dropped job comes back.
- A new curator starts next month and wants to know about every visitor so far. Which helps?
- Opening the guestbook at the first page. Torn-up tickets are gone, and a new pile only gets new tickets. The guestbook kept every line.
- The café team has four readers and the museum has three guestbooks. What does the fourth reader do?
- Nothing: every book already has its one reader from the team. Each book has one reader per team, so its lines are read in order. More readers than books don't help.
- Hanging up Ana's coat is a job for one attendant, and the café wants to know who came today. Where does each go?
- The coat job on the pile, the visit in the guestbook. A job is done once and forgotten; a thing that happened is kept for anyone to read.
- A guestbook reader goes on holiday for a month. The museum removes pages older than a week. What happens when the reader returns?
- The lines on the removed pages are gone unread, and the reader carries on from whatever pages are left. Old pages are taken out on a schedule, whether or not everyone has read them.