By Abhijith N M · Reviewed 24 October 2026 · Editorial standards
Most support requests should stay synchronous: look up, answer, done, inside a second or two. But some work is structurally long - checking an order against the carrier, the warehouse and the payment ledger; drafting a multi-ticket summary; a follow-up scheduled for tomorrow morning; a bulk re-index of policy documents. None of it belongs in the request handler, because the client will time out, the retry will duplicate the work, and a deploy will kill it halfway.
A queue fixes that by turning a function call into a lifecycle. The request does one small thing - validate, record, enqueue - and returns a receipt. A worker does the long thing under the same trace id. The cost is that the surface must handle progress, and the engineering must handle failure honestly.
A job is data. Write down its type, its inputs, its tenant, its idempotency key, its budget and its retry policy, and store it before any worker runs. The worker is replaceable; the record is what lets you retry, audit and explain what happened.
Walk the diagram with a concrete job: a customer asks Harbor Helper to investigate an order that shows delivered but never arrived. The request enqueues an investigate_delivery job with the order id and a dedupe key. The worker loads the job, calls the carrier, the warehouse and the ledger with narrowed read-only tools, and writes one of a small set of outcomes: not_found, carrier_mark_resolved or needs_human. It never issues a refund; when the outcome is needs_human, it creates an approval proposal and a queue item for an agent.
queued.A background agent is still a conversation. The surface should return a job id and a status resource immediately, show honest states (queued, running, waiting for approval, done, failed) and never claim work is finished before the outcome is written. When a job fails permanently, the customer gets a human hand-off with the ticket reference, not a spinner that never resolves.
Key takeaways
Keep fast work in the request; move long, retryable or scheduled work into a job lifecycle.
Store the job as data - type, inputs, tenant, idempotency key, budget and retry policy - before a worker runs.
Claim with a lease and heartbeat, and make every side effect idempotent because delivery is at-least-once.
Checkpoint expensive steps and bound attempts; after the cap, dead-letter the job instead of retrying forever.
Tell the customer the truth through a versioned status resource, including approval waits and permanent failures.
Written and edited by the nexGenCoders team. Spotted a mistake? Tell us and we will fix it.
Don't lose this lesson
Create a free account to save your progress, keep your streak, and work toward a shareable certificate.