---
title: "Messaging patterns with runnable code"
description: "Eleven common messaging patterns, each with a real case and the code that solves it in six languages: work queue, pub/sub, request/reply, workflows, windows, rate limits and more."
---

> Queen MQ documentation, for AI agents
> Complete self-contained summary of Queen MQ: https://queenmq.com/llms-brief.txt
> Fetch that first when the question is about the product rather than about this page.
> Index of all pages: https://queenmq.com/llms.txt

# Messaging patterns with runnable code

The common messaging patterns, one page each, with a real case for each one: the problem, the pattern that solves it with QueenMQ, and the code in the six languages of the SDKs. Every result quoted on these pages comes from programs that run the code and check it, one per language (`book-use-cases` under `examples/tutorials/`).

| Pattern | The case |
| --- | --- |
| [Work queue](/patterns/work-queue/) | Photos resized by three workers, each photo once. |
| [Publish/subscribe](/patterns/publish-subscribe/) | One order read by billing, shipping and analytics. |
| [Request and reply](/patterns/request-reply/) | A price from the pricing service, or "ask us" after half a second. |
| [Ordering and batching](/patterns/ordering-batching/) | A burst of chat messages handled in order, in one call. |
| [Workflows](/patterns/workflows/) | An order moving from paid to shipped, one transaction per step. |
| [Windowed aggregation](/patterns/windowed-aggregation/) | The spans of a trace merged into one record when the trace goes quiet. |
| [Rate limiting](/patterns/rate-limiting/) | SMS sent at most five a second per customer, in order. |
| [Last value](/patterns/last-value/) | Room availability, where only the newest update matters. |
| [Delayed messages](/patterns/delayed-messages/) | A review request a day after checkout, moved or cancelled. |
| [Retries and dead letters](/patterns/retries-dead-letters/) | Webhooks retried with a delay, and filed when they never succeed. |
| [One worker at a time](/patterns/one-worker/) | A nightly report that runs once, on one of three replicas. |

**Why:** most applications are a few of these patterns put together. Seeing each one alone, with its trap, makes the combination easy to read.

Source: https://queenmq.com/patterns/index.mdx
