All concepts
Ordering & dedup

Deduplication ID (FIFO)

Drop duplicate sends inside a 5-minute window.

Why it matters

Lets producers safely retry SendMessage without creating duplicate messages — a critical safety net for at-least-once producers.

What it is

MessageDeduplicationId is a token used by FIFO queues to detect duplicate sends. If you retry SendMessage with the same deduplication ID within a 5-minute interval, Amazon SQS does not introduce duplicates into the queue.

Configuration options

You must configure deduplication in one of two ways:

  • Explicit: provide MessageDeduplicationId on each SendMessage / SendMessageBatch call.
  • Content-based: enable ContentBasedDeduplication — SQS uses SHA-256 hash of the message body (not attributes).
SendMessage({
  QueueUrl: fifoQueueUrl,
  MessageBody: JSON.stringify(event),
  MessageGroupId: orderId,
  MessageDeduplicationId: event.id,  // stable across retries
})

5-minute deduplication interval

SQS tracks deduplication IDs for 5 minutes after each successful send. A second send with the same ID within that window is accepted by the API but not enqueued as a new message.

  • Same payload after 6+ minutes → treated as a new message.
  • Deduplication is per queue, not global across queues.

DLQ interaction

When a message moves from a FIFO queue to a FIFO DLQ, the original deduplication ID is replaced with the original message ID to prevent DLQ deduplication from blocking independent messages that share a deduplication ID.

Gotchas
  • !The window is 5 minutes. The same payload sent 6 minutes later is treated as a new message.
  • !Content-based dedup hashes the body — adding a timestamp or random UUID to the body defeats deduplication.
  • !Deduplication prevents duplicate enqueues, not duplicate processing after visibility timeout expires.