Build reliable asynchronous workflows
Use queues to absorb bursts while respecting retries, ordering, and duplicate delivery.
- Explain backpressure, at-least-once delivery, and the transactional outbox pattern.
A queue separates producers from workers and can absorb short bursts. If work arrives faster than workers can process it, backlog grows; backpressure limits or slows producers before the queue exhausts resources. Many brokers provide at-least-once delivery, so a message may be delivered again after a worker fails. Make handlers idempotent, track retries and dead letters, and use an outbox when a database update and event publication must not get out of sync.
The outbox writes the business update and an event record in one database transaction. A separate publisher sends pending events and marks them delivered; consumers still need idempotency because publication can repeat.
Practice: load a queue
Try it
Up to 15 XPWhen does a queue stop helping?
Try each of these:
- Turn on the burst. Does the queue recover?
- Turn the burst off, then set arrivals above the service rate. What does the line do?
- Keep arrivals high and turn on backpressure. What did you gain, and who pays for it?
Show the numbers as a table
| Time (ticks) | Messages waiting |
|---|---|
| 0 | 0 |
| 1 | 0 |
| 2 | 0 |
| 3 | 0 |
| 4 | 0 |
| 5 | 0 |
| 6 | 0 |
| 7 | 0 |
| 8 | 0 |
| 9 | 0 |
| 10 | 0 |
| 11 | 0 |
| 12 | 0 |
| 13 | 0 |
| 14 | 0 |
| 15 | 0 |
| 16 | 0 |
| 17 | 0 |
| 18 | 0 |
| 19 | 0 |
| 20 | 0 |
| 21 | 0 |
| 22 | 0 |
| 23 | 0 |
| 24 | 0 |
| 25 | 0 |
| 26 | 0 |
| 27 | 0 |
| 28 | 0 |
| 29 | 0 |
| 30 | 0 |
| 31 | 0 |
| 32 | 0 |
| 33 | 0 |
| 34 | 0 |
| 35 | 0 |
| 36 | 0 |
| 37 | 0 |
| 38 | 0 |
| 39 | 0 |
| 40 | 0 |
| 41 | 0 |
| 42 | 0 |
| 43 | 0 |
| 44 | 0 |
| 45 | 0 |
| 46 | 0 |
| 47 | 0 |
| 48 | 0 |
| 49 | 0 |
| 50 | 0 |
| 51 | 0 |
| 52 | 0 |
| 53 | 0 |
| 54 | 0 |
| 55 | 0 |
| 56 | 0 |
| 57 | 0 |
| 58 | 0 |
| 59 | 0 |
- Largest backlog
- 0
- Longest wait
- 0 ticks
- Rejected
- 0
Workers keep up, so the queue stays empty.
Practice: make delivery safe
Try it
Up to 15 XPA message delivered twice
With at-least-once delivery, a worker can finish its job and crash before acknowledging it.
Key takeaways
Queues absorb bursts but do not create processing capacity.
Plan for duplicate delivery and make consumers idempotent.
Use backpressure and monitor queue age, not just queue depth.
Lesson quiz
5 questions · pass with 4 correct · up to 50 XP
Passing this quiz completes the lesson and keeps your streak going. Questions you miss come back in review sessions later.
Questions about this lesson
Stuck? Ask. Figured something out? Share it. Explaining is one of the best ways to learn.
Loading posts…