{"id":"0d59ba99-f759-4b41-83f7-1b1cbfc425d2","task":"Consume messages from AWS SQS reliably using visibility timeout, a dead-letter queue, and idempotent processing","domain":"aws-sqs","steps":["Create a standard or FIFO SQS queue; create a separate dead-letter queue (DLQ) of the same type and configure a redrive policy on the source queue specifying the DLQ ARN and maxReceiveCount (typically 3–5)","Set the queue's VisibilityTimeout to safely exceed your worst-case processing time; if processing can vary, extend visibility mid-flight using ChangeMessageVisibility before the timeout expires","Poll using ReceiveMessage with WaitTimeSeconds up to 20 (long polling) to reduce empty-receive API calls and cost; receive up to 10 messages per call (MaxNumberOfMessages=10)","Process each message and delete it via DeleteMessage using the ReceiptHandle only after successful processing — never delete before confirming success; undeleted messages become visible again after the visibility timeout","Implement idempotency keyed on the message MessageId or a business-level deduplication key stored in a database or ElastiCache; SQS standard queues deliver at least once and occasionally duplicate","Monitor ApproximateNumberOfMessagesNotVisible (in-flight), ApproximateAgeOfOldestMessage, and the DLQ depth in CloudWatch; alert on DLQ depth greater than 0"],"gotchas":["The visibility timeout is per-message, not per-consumer — if your consumer crashes mid-processing, the message reappears after the timeout and will be reprocessed; this is expected behavior, not a bug, so idempotency is non-negotiable","FIFO queues deduplicate within a 5-minute deduplication window using the MessageDeduplicationId — sending the same ID twice in that window silently drops the second message; standard queues have no such deduplication","Long polling (WaitTimeSeconds > 0) is almost always better than short polling; short polling samples only a subset of SQS servers and can return empty responses even when messages exist"],"contributor":"waymark-seed","created":"2026-06-11T21:15:43.680Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"sampled","method":"legacy-file-sample","at":"2026-06-13T18:43:15.651Z"},"url":"https://mcp.waymark.network/r/0d59ba99-f759-4b41-83f7-1b1cbfc425d2"}