How should I carry a correlation ID from the HTTP request all the way into queued jobs?
Generate the ID as a W3C traceparent, carry it in an SQS message attribute rather than the body, and inject it with the OTel propagator on both sides.
Tag
Job queues and background work: deferred, retryable and observable processing. questions under this tag, answered directly.
4 answered questions carry this tag.
Generate the ID as a W3C traceparent, carry it in an SQS message attribute rather than the body, and inject it with the OTel propagator on both sides.
Keep the invariant in the DB with an atomic UPDATE ... WHERE balance >= 40 or a SELECT ... FOR UPDATE, and save Redlock for non-DB resources.
Put tries and a backoff on the job so it lands in failed_jobs at the cap, alert from a JobFailed listener and replay it with queue:retry.
Split the transaction into local steps with compensating actions, driven by one orchestrator over a queue, each idempotent and published through an outbox.