Tarmac

How to Redrive One Specific Message from an SQS DLQ

Retry one AWS SQS dead-letter queue message without moving the whole DLQ. Select it locally, send a copy, then delete the original, with a CLI example and Tarmac steps.

You fixed the bug. Now you want to retry one failed order. The other 8,000 messages in the dead-letter queue can wait their turn.

To redrive one specific SQS DLQ message, receive it, send a copy to the destination queue, then delete the original after the send succeeds. These are separate calls. They are not one atomic move, so your consumer must handle duplicate work safely.

Why bulk redrive is the wrong button

AWS's managed DLQ redrive does not support filtering or editing messages. Its API, StartMessageMoveTask, has no message-ID selector. Setting its rate to one message per second sets the speed, not a total of one message. See AWS DLQ redrive and StartMessageMoveTask.

A one-message retry is a receive, send, and delete workflow. Think of it as giving one order another turn, not opening the floodgates.

Find the message first

SQS cannot receive a message by ID or body filter. Receive a batch, then select from those results locally. Each receive hides those messages for a while and raises their receive counts. An empty batch does not prove your target is absent. See ReceiveMessage.

For a large DLQ, start with How to Search an SQS Queue. Do not confuse a search of received messages with a search of the whole queue.

Retry one message with the AWS CLI

This example uses standard queues, AWS CLI v2 (2.15.47 or later), and jq. Use credentials for the right account and Region. You need sqs:ReceiveMessage and sqs:DeleteMessage on the DLQ, plus sqs:SendMessage on the destination. For KMS-encrypted queues, check the AWS key permissions.

Fix the consumer first. Check that the destination is the queue that should process this job. Coordinate with anyone else receiving or redriving the DLQ during your retry.

1. Receive a small batch

Replace both URLs. The five-minute visibility window below gives you time to inspect the result. Complete the steps while the selected receipt is still valid.

DLQ_URL="https://sqs.us-east-1.amazonaws.com/123456789012/orders-dlq"
DESTINATION_URL="https://sqs.us-east-1.amazonaws.com/123456789012/orders"

aws sqs receive-message \
  --queue-url "$DLQ_URL" \
  --max-number-of-messages 10 \
  --wait-time-seconds 20 \
  --visibility-timeout 300 \
  --message-attribute-names All \
  --message-system-attribute-names All \
  --output json > dlq-batch.json

jq '.Messages[]? | {MessageId, Body, MessageAttributes}' dlq-batch.json

Read the body and confirm the business ID. Copy the SQS MessageId from this batch, not an old producer log.

2. Build the send request for exactly one result

Run the remaining commands in the same shell. Replace the placeholder ID:

TARGET_ID="paste-the-message-id-from-this-batch"

jq -e --arg id "$TARGET_ID" --arg destination "$DESTINATION_URL" '
  [.Messages[]? | select(.MessageId == $id)]
  | if length == 1 then .[0] else error("Expected exactly one matching message") end
  | {
      QueueUrl: $destination,
      MessageBody: .Body,
      MessageAttributes: (.MessageAttributes // {})
    }
' dlq-batch.json > retry-request.json

If this reports an error, stop. Your selected message is not a unique match in this batch. Do not proceed with an old request file.

This keeps the body and custom message attributes. It does not copy SQS system metadata, such as receive count or sent time. If your application uses MessageGroupId for fair queues, add it to retry-request.json as a top-level MessageGroupId key, not inside MessageAttributes. See SendMessage.

3. Send the copy, then remove the original

Review retry-request.json before you run this block. The delete runs only when the send command succeeds:

if aws sqs send-message \
  --cli-input-json file://retry-request.json \
  --cli-binary-format base64 \
  --output json > retry-result.json; then
  RECEIPT_HANDLE=$(jq -er --arg id "$TARGET_ID" '
    [.Messages[]? | select(.MessageId == $id)]
    | if length == 1 then .[0].ReceiptHandle
      else error("Expected exactly one matching message") end
  ' dlq-batch.json) &&
  aws sqs delete-message \
    --queue-url "$DLQ_URL" \
    --receipt-handle "$RECEIPT_HANDLE"
fi

--cli-binary-format base64 is already the CLI v2 default. It is explicit here so that a profile set to raw-in-base64-out cannot re-encode binary attributes copied from the receive result. See the AWS CLI send-message reference.

If the send times out, its outcome may be unknown. Check before sending again. If the send succeeds but the delete fails, a copy can exist in both queues. Resolve the delete; do not repeat the whole send by default.

If the receipt expires, receive the original again before deleting it. Each receive has a new handle. A delete with an old handle may report success without removing the message. See DeleteMessage.

Unselected messages become visible when their five-minute window ends. Check the consumer logs for the job's business ID. A successful send proves SQS accepted the copy, not that the job finished.

What changes for FIFO queues?

Do not run the standard-queue send unchanged. A FIFO destination requires MessageGroupId. Preserve the job's group and choose an explicit, fresh MessageDeduplicationId for this deliberate retry. Reuse that retry ID if you retry the same send after a network error.

Within the five-minute deduplication interval, SQS can accept a send with an already-used deduplication ID without delivering a new message. An explicit ID turns off content-based deduplication for that send. If you leave the ID out on a queue with content-based deduplication, SQS can treat a send with the same body as a duplicate. See SendMessage.

A replay also does not restore the job's old place in the sequence. Check whether later work has already changed the state it depends on. AWS notes the ordering risk in its DLQ guidance.

Prefer a few clicks? Use Tarmac

Tarmac lets you inspect and select a received message before you send it. Search works on your local cache, so the target must be fetched first. Sending and deleting require Tarmac Pro.

  1. Select the DLQ. Set Visibility (min) long enough for your review (default 15, from 1 to 720), then fetch messages.
  2. Search the cache, open the matching message, and check its body and attributes.
  3. Right-click that message and choose Stage send.
  4. Check Destination queue. Enable Delete originals after successful send if you want to remove the DLQ copy. This needs a live receipt.
  5. Choose Stage Send & Delete, or Stage Send if you left the box clear. Open Staged, confirm there is only the intended action, and choose Publish Actions before the receipt expires.

Tarmac sends first and deletes the original only after AWS confirms the send. The same separate-call limits still apply. Review the result, then confirm the job completed in your consumer logs.

Download Tarmac or read the DLQ workflow. Give one message its second chance, and check the result before you invite the rest.

On this page