# Durable beside SQS

The shape: a queue. [Why Durable](https://durablesdk.com/why/vs/sqs) steps this walk
beat by beat; this page is the walk in prose, with the page each beat
reads under Sources, and [Compared](https://durablesdk.com/docs/compare.md) is the table of every
product.

## What SQS gives, as its documentation describes

**At-least-once delivery.** A standard queue delivers each message at least once; a copy can arrive more than once. [1]

**A visibility timeout.** A received message is hidden from other consumers for the timeout; the consumer deletes it when the work is done. [2]

**Redelivery.** A message not deleted before the timeout ends becomes visible again and is received again. [2]

**A dead-letter queue.** After a set number of receives the message moves to a dead-letter queue you name. [3]

**Ordering.** A standard queue orders at best effort; a FIFO queue keeps the order inside a message group. [4][1]

**FIFO deduplication.** A FIFO queue accepts a second message with the same deduplication id inside a deduplication interval and does not deliver it. [5]

## The same work under Durable

**The delivery id is the intent key.** `key: ["messageId"]`. A redelivery joins the one run, and a step already done is served from its row, never called again.

**Each step a row, then the undos in reverse.** The image it found and the image it left, hash-chained, append-only: the record of what each receive changed, written by the engine. The completed steps' undos run in reverse, each its own row, and the run waits in limbo with its rows for a person, no dead-letter queue to read back.

**What the queue leaves to the consumer is an option here.** The key dedupes for the row's life, not for an interval; a delay has no short cap; the retry ladder is declared on the listener; debounce, throttle, priority and fair share are options on a per-row listener; the outbox archives and replays; one failed run waits in limbo, never in a second queue.

**One bad row parks alone.** A per-row listener registered beside a batch listener parks the row it failed on alone, with its run named, while the rows whose reactions completed are delivered in the one statement.

**The agent asks the graph.** `durable-sdk explain <workflow>` prints what the door admits, every step with its undo and its writes, the facts and who listens; `durable-sdk graph walk <subject>` prints the closure from any node; `durable-sdk graph impact --changed` prints what a change reaches before it is made. Offline, over a committed index: an AI coding agent asks before it edits, never guesses.

**Nothing to write but the steps.** No status column, no idempotency check, no compensation by hand, no record kept by hand.

## What you write yourself

| What you write yourself | SQS                                                                                                                     | Durable                                                                                             |
| ----------------------- | ----------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- |
| At-least-once delivery  | An idempotency check in the consumer, keyed on a field you choose and stored somewhere you keep.                        | the intent key, the delivery id; a redelivery joins the one run                                     |
| A visibility timeout    | A deadline on your own work, extended by hand when a step runs long.                                                    | a step's own budget; a wait is a stored timer                                                       |
| Redelivery              | A status column, so the second receive can tell what the first one already did.                                         | the run's row and each step's row; a finished step is served from its row                           |
| A dead-letter queue     | The compensation when the third step of four fails: by hand, before the message moves, with no record of the first two. | the undo declared on the step, run in reverse, ledgered; limbo for a person                         |
| Ordering                | The order of your own steps across receives, when a later receive overtakes an earlier one.                             | the steps of one run in the body's order; facts delivered in partition order                        |
| FIFO deduplication      | The same guard once the interval has passed, and the record of what each receive changed.                               | the key dedupes for the row's life, not for an interval; the ledger holds what each receive changed |

When SQS wins: fire-and-forget fan-out at very large volume, with one idempotent handler that changes nothing worth imaging.

## Sources

1. https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/standard-queues.html
2. https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-visibility-timeout.html
3. https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-dead-letter-queues.html
4. https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/FIFO-queues-understanding-logic.html
5. https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/using-messagededuplicationid-property.html

---

Prompt for an agent:

```text
Read https://durablesdk.com/docs/compare/sqs.md, then decide between Durable and SQS for a keyed multi-step job that outlives a request; run durable-sdk doctor --host before and after; a refused line is a refusal id: durable-sdk explain <id>
```
