Learn

VISUAL GUIDE · APIS & QUEUES

When a job runs twice

Step 1 of 10: Checkout hands off the charge

STEP 1 / 10ORIGINAL SKETCH
enqueueCheckout APIJob queuelease 30 s
A checkout API enqueues a charge job; worker A leases it and writes to the ledger database but its acknowledgement is lost; the queue redelivers to worker B, which writes again unless an idempotency key stops it; an external card provider can also receive the key.
1 / 10
  1. Enqueue
  2. Lease
  3. Side effect
  4. Ack lost
  5. Timeout
  6. Redelivery
  7. At-least-once
  8. Dedupe key
  9. Conditional write
  10. External effects

STEP 1 OF 10 · ENQUEUE

Checkout hands off the charge

The checkout API puts a job on the queue: { job: 7, action: "charge", order: 42, amount: 499 }. It answers the customer right away instead of waiting on the payment work.

The queue now owns the job. Its promise is simple: it will keep handing the job out until someone confirms it is done.

Why it matters. Queues let the front door stay fast and let slow work retry later. That retry promise is also where duplicates come from.