Dead-letter queues and redrive
Stop one bad message from blocking a payment run: configure SQS dead-letter queues with a sensible maxReceiveCount, use partial batch responses in .NET Lambda handlers, alarm on DLQ depth, and redrive messages safely after a fix.
Assumes: .NET 10 LTS · AWS SDK for .NET v4 (AWSSDK.SQS 4.1.0.2) · Amazon.Lambda.SQSEvents 3.0.1 · AWS CLI v2 · CDK v2 (C#) · Terraform AWS provider v6 · Region us-east-1. Verified against official sources on 2026-11-18.
Learning objectives
By the end of this lesson you can:
- Explain what a poison message is and why, without a dead-letter queue (DLQ), it either blocks a queue or silently disappears.
- Configure a redrive policy (
maxReceiveCountplus a DLQ ARN) and a redrive allow policy on Amazon SQS, and choose amaxReceiveCountthat separates transient failures from permanent ones. - Return partial batch responses (
ReportBatchItemFailures) from a .NET Lambda function so one bad message does not force nine good ones to be processed again. - Raise a CloudWatch alarm the moment anything lands in a DLQ, and explain why DLQ retention must be longer than the source queue's.
- Redrive messages back to the source queue with
StartMessageMoveTask, at a controlled rate, only after the cause is fixed, and explain why redrive is only safe when consumers are idempotent.
Prerequisites
- Amazon SQS in depth — visibility timeout, receive count, receipt handles
- Asynchronous communication and event-driven architecture
- Tools: AWS CLI v2 with the
learn-sandboxSSO profile, .NET 10 SDK (or Docker), optionally the AWS CDK CLI or Terraform
Why this matters in banking
It is 06:10 on the last working day of the month. Harbourline's Payments Service consumes a queue of outbound Faster Payments instructions. Overnight, a partner system started sending one instruction with a creditor IBAN that contains a lowercase letter. The validator throws an exception, the message is not deleted, and after 30 seconds it becomes visible again. The consumer picks it up again. And again.
If the queue is FIFO and that instruction sits at the front of its message group, every later payment from the same debtor account waits behind it. Payroll for a small business customer does not go out. If the queue is standard, the other payments still flow, but the bad message is retried thousands of times until the retention period expires after four days, at which point it vanishes. Nobody is told, and the customer's payment is simply lost.
A dead-letter queue turns both failure modes into a controlled, visible event: after a few attempts the message is moved aside, the rest of the queue keeps flowing, an alarm wakes the on-call engineer, and the message is kept safely until someone fixes the cause and redrives it. In a regulated bank, "we know exactly which instructions failed, and we replayed them after the fix" is the answer the operational-resilience team wants to hear. "We lost one" is not.
The idea in plain language
A queue consumer can fail on a message for two very different reasons:
- Transient failure. The database timed out, the downstream API returned 503, the Lambda function ran out of time. Try again in a moment and it will probably work.
- Permanent failure. The message is malformed, refers to an account that does not exist, or triggers a bug in your code. Trying again will fail in exactly the same way, forever.
A message that fails permanently is called a poison message. SQS does not know which kind of failure happened. All it sees is that a consumer received the message and did not delete it before the visibility timeout ran out. So SQS counts: every receive increments the message's ApproximateReceiveCount. A redrive policy on the source queue says "once a message has been received more than N times, stop handing it out and move it to this other queue instead." N is maxReceiveCount, and the other queue is the dead-letter queue.
Later, after you fix whatever caused the failure, you redrive: you move the messages from the DLQ back into the source queue so they are processed normally.
Analogy: A bank's post room sorts incoming letters. If a letter can't be delivered (unreadable address), the clerk tries a few times, then puts it in the "returned mail" tray instead of letting it circulate forever and jam the sorting machine. Someone checks the tray every morning, fixes the address, and puts the letter back into the normal flow. The DLQ is the returned-mail tray,
maxReceiveCountis "how many tries before it goes in the tray", and redrive is "put it back in the flow".
What problem dead-letter queues solve
| Without a DLQ | With a DLQ |
|---|---|
| A poison message is retried until the retention period ends (default 4 days, maximum 14), then deleted silently | It is moved aside after maxReceiveCount receives and kept for inspection |
| On a FIFO queue, a stuck message blocks every later message in the same message group | The blocking message is removed, so the group moves on (but ordering for that group is now broken — see below) |
| Each retry costs a Lambda invocation, logs and possibly downstream calls | Wasted work is bounded to maxReceiveCount attempts |
| Nobody notices until a customer complains | An alarm on DLQ depth fires within minutes |
| No clean way to reprocess after a fix | Redrive moves messages back, at a rate you choose |
What a DLQ is not. A DLQ is an ordinary SQS queue. There is no special queue type. It becomes a DLQ only because another queue's redrive policy points at it. It must be the same type (a FIFO source needs a FIFO DLQ, a standard source needs a standard DLQ), in the same account and Region as the source queue.
Honest limits and sharp edges (verified 2026-11-18):
| Fact | Detail |
|---|---|
| Same account and Region | A DLQ cannot be in another account or Region |
| Same type | FIFO source → FIFO DLQ; standard → standard |
maxReceiveCount | Set per source queue; AWS warns that very low values (such as 1) send messages to the DLQ after a single failed receive. Allowed range 1 to 1,000 ⚠ VERIFY upper bound |
| Retention on standard queues | Expiry is based on the original enqueue time. Moving to a DLQ does not reset the clock |
| Retention on FIFO queues | The enqueue time is reset when a message moves to the DLQ |
| Redrive allow policy | Controls which source queues may use this queue as a DLQ: allowAll (default), byQueue (up to 10 source queue ARNs) or denyAll |
| Redrive task duration | One redrive task runs for at most 36 hours |
| Concurrent redrive tasks | Up to 100 active tasks per account |
| Custom redrive velocity | Up to 500 messages per second |
| Redriven messages | Get a new message ID and a new enqueue time; no filtering or editing during redrive |
Standard queues with maxReceiveCount greater than 3 | After 3 failed receives, SQS moves the message to the back of the queue, so ApproximateAgeOfOldestMessage ignores it |
The retention row deserves its own example. Suppose the source queue keeps messages for 4 days and the DLQ also keeps them for 4 days. A message spends 3 days failing in the source queue before it is moved. On a standard DLQ it is then deleted after only 1 more day, because the clock started when it was first sent. If the alarm fired on a Friday evening and the team looks on Monday, the evidence is gone. Always set the DLQ retention longer than the source queue's; 14 days (the maximum) is a sensible default.
Microsoft / Azure comparison
| You know (Microsoft/Azure) | AWS equivalent | What's different |
|---|---|---|
Service Bus dead-letter subqueue ($DeadLetterQueue) | A separate SQS queue referenced by the source queue's redrive policy | In Service Bus every queue has a built-in DLQ; in SQS you create the DLQ yourself and wire it up |
MaxDeliveryCount on a Service Bus queue (default 10) | maxReceiveCount in the redrive policy | Same idea. SQS has no DLQ until you configure one, so the default is "retry until retention expires" |
DeadLetterReason / DeadLetterErrorDescription properties | None set automatically | SQS doesn't record why a message failed. Log the reason yourself, keyed by message ID |
Explicit DeadLetterMessageAsync() from the consumer | No direct equivalent | You either let the receive count run out, or send the message to the DLQ yourself and delete the original |
| Service Bus Explorer "resubmit" | DLQ redrive (StartMessageMoveTask, console Start DLQ redrive) | AWS's redrive is a managed, rate-limited, asynchronous task |
| MSMQ "transactional dead-letter queue" | SQS DLQ | Same purpose; no MSDTC transactions in SQS |
Azure Functions poison queue (<queue>-poison for Storage queues) | SQS DLQ plus Lambda partial batch responses | Functions creates the poison queue automatically. With Lambda you configure the DLQ on the SQS queue itself |
The biggest mental shift for a Service Bus user: SQS does not dead-letter on its own. A fresh queue with no redrive policy will retry a poison message until the retention period ends and then delete it without telling anyone.
Architecture
Security-boundary view. The DLQ holds exactly the same data as the source queue: payment identifiers, amounts and possibly personal data. Treat it with the same controls: the same encryption (SSE-SQS or SSE-KMS with the same key policy), a queue policy that denies non-TLS access, and IAM permissions that let only the operations role receive from it and start redrives. The consumer function needs no access to the DLQ at all: SQS moves messages there itself. Log message IDs and failure reasons, never message bodies.
How a message reaches the DLQ, step by step
It helps to trace one poison message precisely, because exam questions and production incidents both hinge on the details.
- The producer sends the message.
ApproximateReceiveCountis 0. - Lambda's event source mapping polls the queue and receives a batch including our message. Count is now 1. The message becomes invisible for the visibility timeout (180 seconds in the lab).
- The handler fails it (throws, or lists it in
batchItemFailures). Lambda does not delete it. - After 180 seconds the message becomes visible. The next poll receives it: count 2.
- Steps 3–4 repeat until the count reaches
maxReceiveCount(5). - On the next receive attempt, SQS sees that the count has already reached the limit, and instead of delivering the message it moves it to the DLQ. The consumer never sees a sixth delivery.
So a message with maxReceiveCount = 5 is processed five times before it moves, and the move happens lazily when someone next tries to receive. With a 180-second visibility timeout, that is roughly 15 minutes from first failure to DLQ. If you need the alarm faster, you shorten the visibility timeout or lower the count, and both have costs.
Choosing maxReceiveCount. It must be high enough that a short downstream outage does not dump healthy messages into the DLQ, and low enough that poison messages do not waste hours.
| Situation | Suggested value | Reasoning |
|---|---|---|
| Lambda consumer (AWS guidance) | At least 5 | Lambda can receive a message and then be throttled before invoking your code; that still counts as a receive |
| Downstream outages of up to about 10 minutes, 3-minute visibility | 5 | 5 × 3 minutes ≈ 15 minutes of retrying |
| Long outages expected (e.g. a partner batch window) | Higher count or a longer visibility timeout, plus a circuit breaker | Otherwise every message ends up in the DLQ and you redrive everything |
| FIFO queue where ordering matters more than throughput | Consider no DLQ, or a DLQ with an operational process to stop the group | Moving a message out of a group lets later messages overtake it |
FIFO queues and DLQs: the ordering trade-off
On a FIFO queue, a message that is not deleted blocks every later message with the same message group ID. That is the guarantee you asked for. A DLQ breaks that deadlock by moving the stuck message out, after which message 2, 3 and so on in the group are delivered. For notifications that is exactly what you want. For a ledger it may not be: if message 1 was "open overdraft facility" and message 2 is "debit £500", processing message 2 without message 1 is wrong.
AWS's own guidance is blunt: don't attach a DLQ to a FIFO queue if breaking the exact order of operations is unacceptable. For ledger-like flows at Harbourline, the pattern is:
- Keep the DLQ (losing a posting is worse than pausing one), and
- make the consumer check sequence numbers per account, so a later message that arrives without its predecessor is itself failed and also lands in the DLQ, and
- redrive the whole group in order once fixed.
Delivery guarantees and ordering goes deeper into sequence numbers and out-of-order events.
Two FIFO-specific details:
- When a message moves to a FIFO DLQ, SQS replaces its deduplication ID with its message ID, so two unrelated failed messages that happened to share a deduplication ID are both kept.
- Redrive from a FIFO DLQ must go to a FIFO destination. Redriven messages are interleaved with whatever new messages producers are sending at the same time.
Partial batch responses in Lambda
When Lambda reads from SQS through an event source mapping, it receives up to 10 messages per batch by default (up to 10,000 on standard queues with a batching window). Without extra configuration the rule is all-or-nothing:
- Handler returns normally → Lambda deletes every message in the batch.
- Handler throws → Lambda deletes none of them. All ten become visible again and all ten have their receive count increased.
That second rule is nasty. One poison message in a batch of ten means nine good messages are processed again (duplicate side effects unless you are idempotent) and all ten move towards the DLQ together. With unlucky batching, healthy messages can end up in the DLQ alongside the poison one.
The fix is partial batch responses:
- Turn on
ReportBatchItemFailuresin the event source mapping'sFunctionResponseTypes. - Return an
SQSBatchResponselisting theitemIdentifier(the SQS message ID) of each message that failed. - Lambda deletes everything else.
Rules worth memorising:
| You return | Lambda does |
|---|---|
Empty batchItemFailures | Deletes all messages |
| Some message IDs | Deletes the others; failed ones become visible after the timeout |
| An ID that is not in the batch, or an empty/null ID | Treats the whole batch as failed |
| Function throws an exception | Treats the whole batch as failed |
ReportBatchItemFailures not enabled but you return a response | Response is ignored; success deletes everything |
For FIFO queues, stop processing at the first failure and report that message and every later message in the batch as failed. Otherwise a later message from the same group could be deleted before the earlier failed one is retried, which breaks ordering.
Step-by-step implementation
Create the DLQ first
The DLQ must exist before a redrive policy can point at it. Give it the maximum retention (14 days = 1,209,600 seconds) and the same encryption as the source queue.
Restrict which queues may use it
Set a redrive allow policy of byQueue listing the source queue ARN. That stops an unrelated team from pointing their queue at your DLQ and filling it with their failures (and their personal data).
Attach the redrive policy to the source queue
RedrivePolicy is a JSON string attribute: deadLetterTargetArn plus maxReceiveCount. Choose a visibility timeout of at least six times the Lambda timeout.
Make the consumer report individual failures
Enable ReportBatchItemFailures on the event source mapping and return SQSBatchResponse from the .NET handler. Classify failures: poison (will never succeed) vs transient (may succeed later). Both are reported as failures; the difference is in what you log and whether you also call your downstream again.
Alarm on DLQ depth
Create a CloudWatch alarm on the DLQ's ApproximateNumberOfMessagesVisible, statistic Maximum, threshold greater than 0, one evaluation period of one minute, missing data treated as not breaching. Send it to an SNS topic that pages or emails the on-call team.
Write the runbook before you need it
Who looks at the DLQ, how they inspect messages without leaking personal data, how they decide "fix and redrive" vs "discard", and how they redrive. The module project includes a sample runbook (labs/m08-notification-system/RUNBOOK.md).
Practise a redrive
Inject a poison message, watch it land in the DLQ, deploy a fix (or decide it is bad data), redrive, and confirm no customer got two notifications.
AWS Console instructions
Create the DLQ
- Console → Amazon SQS → Queues → Create queue.
- Type Standard, name
hl-m08-l3-payments-dlq. - Configuration → Message retention period: 14 days.
- Encryption: Server-side encryption enabled, Amazon SQS key (SSE-SQS).
- Redrive allow policy: Enabled → By queue → add the source queue's ARN (you can come back and add it once the source queue exists).
- Add tags
Project=cea-lab,Lab=m08-l3,Environment=learn,Owner=<you>→ Create queue.
Create the source queue with a redrive policy
- Create queue → Standard, name
hl-m08-l3-payments. - Visibility timeout: 180 seconds. Retention: 4 days.
- Dead-letter queue: Enabled → choose
hl-m08-l3-payments-dlq→ Maximum receives: 5. - Same encryption and tags → Create queue.
Redrive after a fix
- Queues → select
hl-m08-l3-payments-dlq→ Start DLQ redrive. - Message destination: Redrive to source queue(s).
- Velocity control settings: Custom max velocity → 10 messages per second (start low).
- Redrive messages. The queue's details page shows progress; Cancel DLQ redrive stops it (messages already moved stay moved).
Alarm
- Console → CloudWatch → Alarms → Create alarm → Select metric → SQS → Queue Metrics →
hl-m08-l3-payments-dlq/ApproximateNumberOfMessagesVisible. - Statistic Maximum, period 1 minute, condition Greater than 0.
- Additional configuration → Missing data treatment → Treat missing data as good (not breaching).
- Notification: an SNS topic for the on-call team. Name
hl-m08-l3-payments-dlq-not-empty.
AWS CLI
export AWS_PROFILE=learn-sandbox AWS_REGION=us-east-1
TAGS='Project=cea-lab,Lab=m08-l3,Environment=learn,Owner=learner'
# 1. DLQ: 14-day retention (seconds), SSE-SQS encryption
DLQ_URL=$(aws sqs create-queue --queue-name hl-m08-l3-payments-dlq \
--attributes MessageRetentionPeriod=1209600,SqsManagedSseEnabled=true \
--tags "$TAGS" --query QueueUrl --output text)
DLQ_ARN=$(aws sqs get-queue-attributes --queue-url "$DLQ_URL" \
--attribute-names QueueArn --query Attributes.QueueArn --output text)
# 2. Source queue with a redrive policy (the policy value is a JSON string inside JSON)
cat > source-attrs.json <<EOF
{
"VisibilityTimeout": "180",
"MessageRetentionPeriod": "345600",
"SqsManagedSseEnabled": "true",
"RedrivePolicy": "{\"deadLetterTargetArn\":\"$DLQ_ARN\",\"maxReceiveCount\":\"5\"}"
}
EOF
SRC_URL=$(aws sqs create-queue --queue-name hl-m08-l3-payments \
--attributes file://source-attrs.json --tags "$TAGS" --query QueueUrl --output text)
SRC_ARN=$(aws sqs get-queue-attributes --queue-url "$SRC_URL" \
--attribute-names QueueArn --query Attributes.QueueArn --output text)
# 3. Only this source queue may use the DLQ
cat > allow.json <<EOF
{ "RedriveAllowPolicy": "{\"redrivePermission\":\"byQueue\",\"sourceQueueArns\":[\"$SRC_ARN\"]}" }
EOF
aws sqs set-queue-attributes --queue-url "$DLQ_URL" --attributes file://allow.json
# 4. Which queues send to this DLQ?
aws sqs list-dead-letter-source-queues --queue-url "$DLQ_URL"
# 5. Simulate a poison message and a consumer that never deletes it.
aws sqs send-message --queue-url "$SRC_URL" --message-body '{"paymentId":"PAY-bad","creditorIban":"gb82west12345698765432"}'
# For a quick drill, receive it 6 times with a 0-second visibility timeout:
for i in 1 2 3 4 5 6; do
aws sqs receive-message --queue-url "$SRC_URL" --visibility-timeout 0 \
--message-system-attribute-names ApproximateReceiveCount \
--query 'Messages[0].Attributes.ApproximateReceiveCount' --output text
done
# The 6th attempt returns None: the message has moved to the DLQ.
aws sqs get-queue-attributes --queue-url "$DLQ_URL" --attribute-names ApproximateNumberOfMessages
# 6. Redrive back to the source queue at 10 messages per second
aws sqs start-message-move-task --source-arn "$DLQ_ARN" --max-number-of-messages-per-second 10
aws sqs list-message-move-tasks --source-arn "$DLQ_ARN" --max-results 1
# Cancel a running task if you redrove too early:
# aws sqs cancel-message-move-task --task-handle <TaskHandle from start-message-move-task>
# 7. Alarm on DLQ depth (add --alarm-actions <sns-topic-arn> to be notified)
aws cloudwatch put-metric-alarm --alarm-name hl-m08-l3-payments-dlq-not-empty \
--namespace AWS/SQS --metric-name ApproximateNumberOfMessagesVisible \
--dimensions Name=QueueName,Value=hl-m08-l3-payments-dlq \
--statistic Maximum --period 60 --evaluation-periods 1 \
--threshold 0 --comparison-operator GreaterThanThreshold \
--treat-missing-data notBreachingNotes on the commands:
RedrivePolicyandRedriveAllowPolicyare strings containing JSON, which is why the inner quotes are escaped. Writing them into a file avoids PowerShell and Bash quoting pain.- In step 5 a visibility timeout of 0 makes the message visible again immediately. Never use 0 in a real consumer: it means "anybody can grab this message right now while I am still processing it".
start-message-move-taskwithout--destination-arnsends each message back to the queue it came from. That only works for messages that arrived in the DLQ through a redrive policy; messages you put there by hand withsend-messagehave no recorded source and need an explicit destination.
Infrastructure as Code
using Amazon.CDK;
using Amazon.CDK.AWS.CloudWatch;
using Amazon.CDK.AWS.CloudWatch.Actions;
using Amazon.CDK.AWS.SNS;
using Amazon.CDK.AWS.SQS;
using Constructs;
namespace Harbourline.Payments.Infra;
public sealed class PaymentsQueueStack : Stack
{
public PaymentsQueueStack(Construct scope, string id, IStackProps? props = null) : base(scope, id, props)
{
var dlq = new Queue(this, "PaymentsDlq", new QueueProps
{
QueueName = "hl-m08-l3-payments-dlq",
RetentionPeriod = Duration.Days(14), // longer than the source queue
Encryption = QueueEncryption.SQS_MANAGED,
EnforceSSL = true,
});
var queue = new Queue(this, "PaymentsQueue", new QueueProps
{
QueueName = "hl-m08-l3-payments",
VisibilityTimeout = Duration.Seconds(180), // 6 x a 30-second Lambda timeout
RetentionPeriod = Duration.Days(4),
Encryption = QueueEncryption.SQS_MANAGED,
EnforceSSL = true,
DeadLetterQueue = new DeadLetterQueue { Queue = dlq, MaxReceiveCount = 5 },
});
// Redrive allow policy: only our source queue may dead-letter into this DLQ.
var cfnDlq = (CfnQueue)dlq.Node.DefaultChild!;
cfnDlq.RedriveAllowPolicy = new Dictionary<string, object>
{
["redrivePermission"] = "byQueue",
["sourceQueueArns"] = new[] { queue.QueueArn },
};
var onCall = new Topic(this, "OnCall", new TopicProps { TopicName = "hl-m08-l3-oncall", EnforceSSL = true });
var alarm = new Alarm(this, "DlqNotEmpty", new AlarmProps
{
AlarmName = "hl-m08-l3-payments-dlq-not-empty",
AlarmDescription = "Payments failed after 5 attempts. See the runbook before redriving.",
Metric = dlq.MetricApproximateNumberOfMessagesVisible(new MetricOptions
{
Period = Duration.Minutes(1),
Statistic = "Maximum",
}),
Threshold = 0,
ComparisonOperator = ComparisonOperator.GREATER_THAN_THRESHOLD,
EvaluationPeriods = 1,
TreatMissingData = TreatMissingData.NOT_BREACHING,
});
alarm.AddAlarmAction(new SnsAction(onCall));
}
}Wait: there is a circular reference in this snippet. The DLQ's allow policy refers to the source queue's ARN, and the source queue's redrive policy refers to the DLQ's ARN. CloudFormation cannot create two resources that each need the other's ARN. Two ways out:
- Build the source queue ARN as a string from its name instead of a token:
$"arn:aws:sqs:{Region}:{Account}:hl-m08-l3-payments"(it works because you chose the name), or - Leave the allow policy at its default (
allowAll) and restrict access with IAM instead.
["sourceQueueArns"] = new[] { $"arn:{Partition}:sqs:{Region}:{Account}:hl-m08-l3-payments" },Spotting dependency cycles like this is part of reading IaC critically. cdk synth would report it as Circular dependency between resources.
Complete code
Two pieces of runnable .NET code: the Lambda handler that reports partial batch failures, and an operations console tool that inspects a DLQ and starts a redrive. The full, tested version of the handler is in labs/m08-notification-system/src/Harbourline.Notifications.Functions.
The handler: classify, report, never throw for one message
using System.Text.Json;
using Amazon.Lambda.Core;
using Amazon.Lambda.SQSEvents;
[assembly: LambdaSerializer(typeof(Amazon.Lambda.Serialization.SystemTextJson.DefaultLambdaJsonSerializer))]
namespace Harbourline.Payments.Functions;
public sealed record PaymentInstruction(string PaymentId, string DebtorAccountId, string CreditorIban, decimal Amount, string Currency);
/// <summary>Thrown for failures that will never succeed on retry.</summary>
public sealed class PoisonMessageException(string reason) : Exception(reason);
public sealed class PaymentInstructionFunction
{
private static readonly JsonSerializerOptions Json = new(JsonSerializerDefaults.Web);
public async Task<SQSBatchResponse> HandleAsync(SQSEvent sqsEvent, ILambdaContext context)
{
var failures = new List<SQSBatchResponse.BatchItemFailure>();
var isFifo = sqsEvent.Records is { Count: > 0 } records
&& records[0].EventSourceArn.EndsWith(".fifo", StringComparison.Ordinal);
foreach (var record in sqsEvent.Records ?? [])
{
// FIFO: once one message fails, fail the rest of the batch to keep group order.
if (isFifo && failures.Count > 0)
{
failures.Add(new SQSBatchResponse.BatchItemFailure { ItemIdentifier = record.MessageId });
continue;
}
try
{
var instruction = Parse(record.Body);
await SubmitAsync(instruction);
}
catch (PoisonMessageException ex)
{
Log(context, record, "poison", ex.Message);
failures.Add(new SQSBatchResponse.BatchItemFailure { ItemIdentifier = record.MessageId });
}
catch (Exception ex)
{
Log(context, record, "transient", ex.GetType().Name);
failures.Add(new SQSBatchResponse.BatchItemFailure { ItemIdentifier = record.MessageId });
}
}
return new SQSBatchResponse { BatchItemFailures = failures };
}
private static PaymentInstruction Parse(string body)
{
PaymentInstruction? instruction;
try
{
instruction = JsonSerializer.Deserialize<PaymentInstruction>(body, Json);
}
catch (JsonException)
{
throw new PoisonMessageException("body is not valid JSON");
}
if (instruction is null || !instruction.PaymentId.StartsWith("PAY-", StringComparison.Ordinal))
throw new PoisonMessageException("paymentId missing or malformed");
if (instruction.CreditorIban != instruction.CreditorIban.ToUpperInvariant())
throw new PoisonMessageException("creditor IBAN is not upper case");
if (instruction.Amount <= 0m)
throw new PoisonMessageException("amount must be positive");
return instruction;
}
// Stand-in for the call to the payment scheme gateway. Must be idempotent on PaymentId.
private static Task SubmitAsync(PaymentInstruction instruction) => Task.CompletedTask;
private static void Log(ILambdaContext context, SQSEvent.SQSMessage record, string kind, string reason)
{
var receiveCount = record.Attributes?.GetValueOrDefault("ApproximateReceiveCount") ?? "?";
// Identifiers and reasons only. Never log the body: it contains an IBAN.
context.Logger.LogWarning(JsonSerializer.Serialize(new { messageId = record.MessageId, receiveCount, kind, reason }));
}
}The operations tool: peek, summarise, redrive
using Amazon.SQS;
using Amazon.SQS.Model;
// Usage (AWS_PROFILE=learn-sandbox, AWS_REGION=us-east-1):
// dotnet run -- inspect hl-m08-l3-payments-dlq
// dotnet run -- redrive hl-m08-l3-payments-dlq 10
// dotnet run -- status hl-m08-l3-payments-dlq
if (args.Length < 2)
{
Console.WriteLine("Usage: inspect|redrive|status <dlq-name> [messagesPerSecond]");
return 1;
}
using var sqs = new AmazonSQSClient();
var dlqUrl = (await sqs.GetQueueUrlAsync(new GetQueueUrlRequest { QueueName = args[1] })).QueueUrl;
var attrs = await sqs.GetQueueAttributesAsync(new GetQueueAttributesRequest
{
QueueUrl = dlqUrl,
AttributeNames = ["QueueArn", "ApproximateNumberOfMessages"],
});
var dlqArn = attrs.Attributes["QueueArn"];
switch (args[0])
{
case "inspect":
// Receive with a short visibility timeout: we look, we do not delete.
var response = await sqs.ReceiveMessageAsync(new ReceiveMessageRequest
{
QueueUrl = dlqUrl,
MaxNumberOfMessages = 10,
VisibilityTimeout = 30,
WaitTimeSeconds = 2,
MessageSystemAttributeNames = ["ApproximateReceiveCount", "SentTimestamp", "DeadLetterQueueSourceArn"],
});
Console.WriteLine($"Approximate depth: {attrs.Attributes["ApproximateNumberOfMessages"]}");
foreach (var m in response.Messages ?? [])
{
var sent = m.Attributes is not null && m.Attributes.TryGetValue("SentTimestamp", out var ts)
? DateTimeOffset.FromUnixTimeMilliseconds(long.Parse(ts, System.Globalization.CultureInfo.InvariantCulture)).ToString("u")
: "?";
var source = m.Attributes?.GetValueOrDefault("DeadLetterQueueSourceArn") ?? "(sent directly)";
// Show size and a hash, not the content: the body may hold personal data.
var hash = Convert.ToHexString(System.Security.Cryptography.SHA256.HashData(System.Text.Encoding.UTF8.GetBytes(m.Body)))[..12];
Console.WriteLine($"{m.MessageId} sent {sent} bytes {m.Body.Length,6} sha256 {hash} from {source}");
}
return 0;
case "redrive":
var rate = args.Length > 2 ? int.Parse(args[2], System.Globalization.CultureInfo.InvariantCulture) : 10;
var task = await sqs.StartMessageMoveTaskAsync(new StartMessageMoveTaskRequest
{
SourceArn = dlqArn, // the DLQ is the SOURCE of a move task
MaxNumberOfMessagesPerSecond = rate, // omit for "system optimised"
// DestinationArn omitted: each message goes back to the queue it came from.
});
Console.WriteLine($"Started move task {task.TaskHandle} at {rate} msg/s");
return 0;
case "status":
var tasks = await sqs.ListMessageMoveTasksAsync(new ListMessageMoveTasksRequest { SourceArn = dlqArn, MaxResults = 3 });
foreach (var t in tasks.Results ?? [])
{
Console.WriteLine($"{t.Status,-10} moved {t.ApproximateNumberOfMessagesMoved}/{t.ApproximateNumberOfMessagesToMove} {t.FailureReason}");
}
return 0;
default:
Console.WriteLine($"Unknown command {args[0]}");
return 1;
}<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AWSSDK.SQS" Version="4.1.0.2" />
</ItemGroup>
</Project>Code explained line by line
Handler
[assembly: LambdaSerializer(...)]— tells the Lambda runtime how to turn the incoming JSON event intoSQSEventand the returnedSQSBatchResponseback into JSON.HandleAsyncreturnsTask<SQSBatchResponse>— this return type is what makes partial batch responses possible. It only has an effect whenReportBatchItemFailuresis enabled on the event source mapping.isFifo— the event source ARN of a FIFO queue ends in.fifo. For FIFO we stop after the first failure and fail everything after it, so a later message in the same group can't be deleted ahead of an earlier failed one.- The
trywraps one message. An exception for one message never escapes the loop; escaping would fail the whole batch. PoisonMessageExceptionvsException— both are reported as failures. The difference is in the log: on-call engineers can count poison vs transient failures with a Logs Insights query and immediately see whether they face bad data or an outage.Parse— validation rules that will fail identically on every retry are poison by definition. A lowercase IBAN is our month-end scenario.SubmitAsync— the comment matters: because SQS redelivers, and because redrive replays, the submission must be idempotent onPaymentId. See Idempotency in .NET.Log— writes structured JSON with the message ID and receive count. It deliberately leaves out the body, which contains an IBAN.
Operations tool
GetQueueUrlAsync/GetQueueAttributesAsync— turns the name into a URL and fetches the ARN (needed by the move-task APIs) and depth. In SDK v4,AttributeNamesis aList<string>, and collection expressions ([...]) keep it short.ReceiveMessageAsyncwithVisibilityTimeout = 30— receiving from a DLQ hides messages for that period. Keep it short so an operator's peek doesn't interfere with a redrive that starts a minute later.MessageSystemAttributeNames— the SDK v4 property for system attributes.DeadLetterQueueSourceArntells you which source queue the message came from.response.Messages ?? []— SDK v4 returnsnullfor empty collections, not an empty list. Forgetting this is the most common v3-to-v4 migration bug.- The SHA-256 prefix lets two engineers confirm they are looking at the same message without pasting its content into a chat channel.
StartMessageMoveTaskAsync— note that the DLQ is the source of a move task. The rate is capped byMaxNumberOfMessagesPerSecond; omitting it lets SQS choose ("system optimised").ListMessageMoveTasksAsync— returns up to the 10 most recent tasks for the queue with status (RUNNING,COMPLETED,CANCELLING,CANCELLED,FAILED) and counts.
Security considerations
⚠ Learning shortcut — not for production
The CLI drill uses your sandbox administrator role to receive from the DLQ and to start a redrive. In production, create a dedicated operations role with only sqs:ReceiveMessage, sqs:GetQueueAttributes, sqs:StartMessageMoveTask, sqs:CancelMessageMoveTask, sqs:ListMessageMoveTasks, sqs:ListDeadLetterSourceQueues and sqs:DeleteMessage on the DLQ ARN, plus sqs:SendMessage on the destination queue (and kms:Decrypt / kms:GenerateDataKey if you use SSE-KMS). Require MFA through IAM Identity Center and log every redrive in CloudTrail.
- Same protection as the source. A DLQ full of failed payment instructions is a concentrated store of personal and financial data. Encrypt it with the same key, restrict who can read it, and keep its retention as short as your process allows (14 days is the maximum, not a requirement).
- Redrive allow policy. Use
byQueueso that only your own source queues can dead-letter into your DLQ. - Don't log bodies. Log message IDs, receive counts, error categories and hashes. If engineers need to see content, do it in a controlled tool with access logging, not by copying JSON into tickets.
- Redrive is a privileged action. It can trigger real side effects (payments, notifications). Treat it like a change: a ticket, a reason, and a second pair of eyes for large redrives.
- Discarding is also a decision. Purging a DLQ deletes evidence. Agree with the data owner and record the decision; for payment instructions, the business usually needs to tell the customer.
- GDPR / UK GDPR. Retention of personal data in DLQs and archives needs review by your data-protection team. This lesson does not make a design compliant.
Banking use case
Harbourline's Notifications Service (the module project) runs one SQS queue per channel. In the first week of production:
- Monday: a publisher bug sends
currency: "POUNDS"for 37 transactions. The handler classifies them as poison. After five receives each they land inhl-m08-notify-sms-dlq, the alarm fires at 09:14, and the on-call engineer's Logs Insights query shows37 × poison: currency is not a 3-letter ISO 4217 code. The publishing team fixes their mapping. The 37 messages themselves are still invalid, so they are not redriven. Instead the publisher re-sends corrected events. - Wednesday: the SMS provider has a 40-minute outage. Each message is retried five times over 15 minutes, then 2,300 messages land in the DLQ. When the provider recovers, the engineer redrives at 20 messages per second to avoid flooding it. The idempotency table ensures that the 12 messages that were actually delivered just before the provider's API started timing out are not sent twice.
- Lesson learned: for the outage case,
maxReceiveCount = 5with a 3-minute visibility timeout was too eager. The team adds a circuit breaker: when the provider is failing, the handler stops calling it and reports all messages as failed quickly. They also consider a longer visibility timeout for that queue. Retry strategies covers the design.
Common mistakes
- No DLQ at all. Poison messages loop until retention expires and then vanish. → Every production queue gets a DLQ and an alarm; make it a cdk-nag or policy-as-code rule (cdk-nag's
AwsSolutions-SQS3flags queues without one). - DLQ retention equal to or shorter than the source. On standard queues messages expire based on the original enqueue time and disappear from the DLQ early. → 14 days on DLQs.
maxReceiveCount = 1. One Lambda throttle or a single timeout sends a healthy message to the DLQ. → At least 5 for Lambda consumers.- Throwing from the Lambda handler for one bad message. The whole batch is retried; good messages are reprocessed and pushed towards the DLQ. → Partial batch responses.
- Returning
batchItemFailureswithout enablingReportBatchItemFailures. Lambda ignores the response and deletes every message on success. The bad message is silently lost. → Enable it on the event source mapping and test it. - Redriving before fixing. Messages fail five more times and come straight back, and you have spent another 15 minutes. → Redrive only after a fix, or after confirming the outage is over.
- Redriving into a non-idempotent consumer. Some messages in the DLQ were partly processed (the side effect happened, then the delete failed). Redrive repeats the side effect. → Idempotency keys based on business identifiers.
- Alarming on the source queue's age only. With
maxReceiveCountabove 3 on standard queues, SQS moves repeatedly failing messages to the back, andApproximateAgeOfOldestMessagestops reflecting them. → Alarm on DLQ depth as well. - One DLQ shared by many unrelated queues. You can't tell where failures came from or redrive selectively. → One DLQ per source queue (the
DeadLetterQueueSourceArnattribute helps, but separate queues are clearer).
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| Poison message is retried forever, DLQ stays empty | No redrive policy on the source queue, or it points at the wrong ARN | aws sqs get-queue-attributes --attribute-names RedrivePolicy; check the ARN and count |
InvalidParameterValue when setting RedrivePolicy | DLQ is a different type (FIFO vs standard) or in another Region/account | Create a matching DLQ in the same account and Region |
| Setting the redrive policy fails with a permission-style error | DLQ's redrive allow policy is denyAll or byQueue without this source | Add the source ARN to sourceQueueArns |
| Messages vanish from the DLQ sooner than its retention | Standard queue: expiry counts from the original enqueue time | Increase DLQ retention to 14 days |
| Good messages show up in the DLQ | Whole batch failing (no partial batch responses), visibility timeout shorter than processing time, or maxReceiveCount too low | Enable ReportBatchItemFailures; visibility ≥ 6 × function timeout; count ≥ 5 |
Redrive task FAILED with an access error | Missing sqs:SendMessage on destination or kms:Decrypt/kms:GenerateDataKey for encrypted queues | Add the permissions to the operator role / key policy |
start-message-move-task without a destination fails | Messages were sent to the DLQ manually, so there is no recorded source queue | Pass --destination-arn explicitly |
| DLQ alarm never fires even though messages arrive | Wrong metric (e.g. NumberOfMessagesSent is not emitted for messages moved by redrive policy), or missing data treated as breaching/ignored inconsistently | Use ApproximateNumberOfMessagesVisible with Maximum ⚠ VERIFY metric behaviour for moved messages |
| Messages redriven but processed twice | Consumer is not idempotent | Add an idempotency table keyed on a business ID |
Cost and cleanup
Cost: free at lab volumes. A DLQ is an ordinary SQS queue: you pay only for requests, and the first 1 million SQS requests per month are free. Moving a message to a DLQ and redriving it each count as requests. The CloudWatch alarm is one standard alarm; the CloudWatch free tier includes 10 alarms per month, and a standard alarm costs about USD 0.10 per month beyond that ⚠ VERIFY on the CloudWatch pricing page. This lesson's drill uses a few dozen requests.
Free alternative: the module project's offline simulator (dotnet run --project src/Harbourline.Notifications.Cli -- simulate) reproduces receive counts, DLQ moves and redrive without an AWS account.
Teardown:
export AWS_PROFILE=learn-sandbox AWS_REGION=us-east-1
aws cloudwatch delete-alarms --alarm-names hl-m08-l3-payments-dlq-not-empty
for q in hl-m08-l3-payments hl-m08-l3-payments-dlq; do
url=$(aws sqs get-queue-url --queue-name "$q" --query QueueUrl --output text) && aws sqs delete-queue --queue-url "$url"
done
rm -f source-attrs.json allow.json
# Nothing tagged for this lesson should remain (tag data may lag a few minutes)
aws resourcegroupstaggingapi get-resources --tag-filters Key=Project,Values=cea-lab Key=Lab,Values=m08-l3 \
--query 'ResourceTagMappingList[].ResourceARN'With CDK: cdk destroy. With Terraform: terraform destroy.
Exercises
- 🟢 Guided: Run the CLI section end to end. Record the
ApproximateReceiveCountprinted by each of the six receives, confirm the message is in the DLQ, then redrive it and confirm it is back in the source queue with a new message ID. - 🟡 Challenge: Deploy the handler above with an SQS event source mapping (batch size 10,
ReportBatchItemFailureson). Send 9 valid instructions and 1 with a lowercase IBAN in one go. Prove from CloudWatch Logs that the 9 were processed exactly once and only the bad one was retried. - 🔴 Live problem: Ticket from the payments operations lead: "Since last night's release the payments DLQ alarm has fired three times. Each time someone redrove the DLQ and the alarm fired again 15 minutes later. 4,100 instructions are now in the DLQ, including some that look perfectly valid. The cut-off for today's Faster Payments submission window is 15:00. What do we do?" Write your incident plan.
Assignment
Add a DLQ, redrive allow policy and depth alarm to a queue in your own portfolio project (or to the hl-m08-l3-payments queue). Include in the README: your chosen maxReceiveCount and visibility timeout with the reasoning, a one-page runbook (when to redrive, when to discard, who approves), and a screenshot-free description of a drill you ran with timestamps.
Solutions
The six receives print 1, 2, 3, 4, 5 and then None. The first five deliveries each increment the receive count. On the sixth attempt SQS sees the count has reached maxReceiveCount = 5 and moves the message to the DLQ instead of delivering it, so the receive returns nothing. get-queue-attributes on the DLQ then shows ApproximateNumberOfMessages: 1.
After start-message-move-task, list-message-move-tasks shows COMPLETED with 1 moved. Receiving from the source queue returns the message with a different MessageId, because redriven messages are new messages with a new ID and enqueue time. That is why idempotency keys must be based on business IDs (here paymentId), never on SQS message IDs.
Create the mapping with aws lambda create-event-source-mapping --function-name <fn> --event-source-arn <queue-arn> --batch-size 10 --function-response-types ReportBatchItemFailures. Send the 10 messages with send-message-batch so they arrive together.
In CloudWatch Logs Insights:
fields @timestamp, messageId, receiveCount, kind
| filter ispresent(kind)
| sort @timestamp ascYou should see one poison line for the bad message with receiveCount 1, then 2, 3, 4, 5 on later invocations, and no warning lines for the other nine. If the nine valid messages also appear multiple times, the mapping is missing ReportBatchItemFailures (check with aws lambda get-event-source-mapping → FunctionResponseTypes) or the handler threw instead of returning failures.
- Stop the loop. Do not redrive again. Each redrive puts 4,100 messages through five more failures.
- Classify. Logs Insights grouped by
kind, reasonsince the release. Two populations are likely: genuinely bad messages (a new validation rule in the release rejects something the partner sends), and valid-looking messages that failed for another reason (e.g. the release also shortened the function timeout, or broke a dependency). - Decide on the release. If the release introduced the failure, roll back (or fix forward) first. That is the fix.
- Redrive in a controlled way. After the fix is confirmed with a single test message, redrive at a modest rate (e.g. 20 per second, about 3.5 minutes for 4,100) and watch the DLQ and the error rate. Cancel the move task if failures reappear.
- Handle what stays poison. Anything still failing after the fix is real bad data: export identifiers (not bodies) to the partner, agree a correction, and record the decision.
- Protect against duplicates. Before redriving, confirm the scheme submission is idempotent on
PaymentId, because some messages may have been submitted before failing on a later step. - Afterwards. Add a release check (canary or a contract test with the partner's sample file), and alarm on the rate of poison classifications, not just DLQ depth. The 15:00 cut-off goes into the incident record. If it is missed, customer communications need a business decision.
Knowledge check
Answer: About 1 day after it arrives in the DLQ. For standard queues, expiry is based on the original enqueue timestamp, which moving to a DLQ does not change. (For a FIFO DLQ the enqueue time resets, so it would stay 4 days.) The fix is to give DLQs a longer retention, ideally 14 days.
Answer: Lambda considers the whole batch failed. None of the 10 messages are deleted; all become visible again after the visibility timeout with their receive counts increased. The 9 good ones are processed again (duplicate side effects unless idempotent) and all 10 move towards the DLQ together.
Answer: Lambda's pollers can receive a message and then fail to invoke the function (for example due to throttling when concurrency is exhausted). That receive still increments the count. A low value lets healthy messages reach the DLQ without your code ever having run on them.
Answer: The DLQ. You move messages from the DLQ. The destination defaults to each message's original source queue, or you name one with DestinationArn.
Answer: A DLQ removes a stuck message from its message group so later messages can proceed. That unblocks the group but breaks strict ordering: later messages are processed before the failed one. Where order is essential (ledger postings), the consumer must detect gaps or the team must pause and redrive the group in order.
Interview questions
- "How do you handle poison messages in SQS?" — A redrive policy with a DLQ and a
maxReceiveCountsized to the retry budget (at least 5 with Lambda), partial batch responses so one bad message doesn't fail a batch, an alarm on DLQ depth, a runbook, and redrive after the fix. Consumers are idempotent so redrive is safe. - "What's the difference between a transient and a permanent failure, and does SQS know?" — Transient failures may succeed later (timeouts, 503s); permanent ones never will (bad data, bugs). SQS can't tell them apart: it only counts receives. Your code should classify them for logging and alerting, and may short-circuit permanent ones, but both end up as "not deleted".
- "A message was redriven and processed twice. Why, and how do you prevent it?" — The message may have been partly processed before failing (side effect done, delete not), and redriven messages get a new message ID. Prevent it with an idempotency key derived from a business identifier, stored with a conditional write.
- "Why might DLQ messages disappear early?" — Standard queue expiry uses the original enqueue time. If the DLQ's retention isn't longer than the source's, messages can expire soon after arriving.
- "How would you redrive 50,000 messages after an outage?" — Confirm the downstream is healthy, test one message, then redrive with a capped velocity, watch error rates and the DLQ, and be ready to cancel the move task. Make sure the consumer's concurrency is capped too (event source mapping maximum concurrency).
Certification practice
A Lambda function processes an Amazon SQS standard queue with a batch size of 10. When a single malformed message is in a batch, the logs show the other nine messages being processed two or three times. Which change fixes this with the LEAST code change?
A. Reduce the batch size to 1.
B. Enable ReportBatchItemFailures on the event source mapping and return the IDs of failed messages from the handler.
C. Convert the queue to a FIFO queue.
D. Increase the queue's visibility timeout to 12 hours.
Answer: B. Partial batch responses let Lambda delete the successful messages and retry only the failed one. A works but reduces throughput dramatically and increases cost. C does not change the all-or-nothing batch behaviour. D only delays the retries.
A bank's payment instructions are processed from an SQS standard queue with a 4-day retention period. The operations team must be able to examine and reprocess any instruction that cannot be processed, for up to 10 days after it was first sent. Which design meets the requirement?
A. Configure a DLQ with a 4-day retention period and maxReceiveCount of 3.
B. Configure a DLQ with a 14-day retention period and maxReceiveCount of 5, and alarm on the DLQ's visible message count.
C. Increase the source queue retention to 14 days and do not use a DLQ.
D. Configure an SNS topic as the dead-letter target.
Answer: B. Expiry for standard queues is based on the original enqueue time, so the DLQ needs a retention period longer than 10 days; 14 days does it. A expires messages too soon. C lets poison messages retry for 14 days and never isolates them. D is not supported: an SQS DLQ must be an SQS queue of the same type in the same account and Region.
A developer fixed a bug that caused 2,000 messages to move to a DLQ. The downstream API can handle about 25 requests per second. How should the developer return the messages for processing?
A. Write a script that receives each message from the DLQ and sends it to the source queue as fast as possible.
B. Use StartMessageMoveTask on the DLQ with MaxNumberOfMessagesPerSecond set to 20.
C. Delete the source queue's redrive policy so the messages return automatically.
D. Purge the DLQ and ask the producers to resend.
Answer: B. The managed move task is asynchronous, resumable to cancel, and rate-limited. A works but risks overwhelming the API and re-implements a managed feature. C does nothing to messages already in the DLQ. D loses data and depends on producers keeping copies.
An SQS FIFO queue carries account postings grouped by account ID. A posting fails repeatedly due to a bug and blocks all later postings for that account. The business says later postings must never be applied before an earlier failed one. What should the architect recommend?
A. Attach a DLQ with maxReceiveCount 1 so the queue is never blocked.
B. Attach a DLQ, make the consumer reject postings whose predecessor sequence number has not been applied, and redrive the group in order after the fix.
C. Switch to a standard queue to avoid blocking.
D. Increase the visibility timeout so the failed message is retried less often.
Answer: B. A DLQ prevents indefinite blocking, and sequence checks stop out-of-order application; the whole group is replayed in order once fixed. A lets later postings overtake the failed one. C removes ordering altogether. D only slows the retries and keeps the group blocked.
Completion checklist
- I can explain poison messages,
maxReceiveCountand redrive to a colleague in two minutes - I created a queue with a DLQ, redrive allow policy and depth alarm
- I watched a message reach the DLQ after exactly
maxReceiveCountreceives - I redrove a message and saw that it came back with a new message ID
- I can explain partial batch responses and the FIFO rule for them
- I ran the teardown and confirmed nothing tagged
Lab=m08-l3remains
Key takeaways
- SQS never dead-letters by itself. Every production queue needs a redrive policy, a DLQ of the same type in the same account and Region, and an alarm on DLQ depth.
- Choose
maxReceiveCountas a retry budget (at least 5 with Lambda) and set DLQ retention longer than the source: standard-queue expiry counts from the original send time. - Use partial batch responses in Lambda so one poison message never re-runs nine good ones; on FIFO, fail everything after the first failure.
- Redrive only after a fix, at a controlled rate, into idempotent consumers. Redriven messages get new message IDs.
- A DLQ is a store of sensitive data: same encryption, least-privilege access, no bodies in logs, and a documented decision whenever you discard.
Further reading
Independent learning resource — not affiliated with, endorsed or sponsored by Amazon Web Services. AWS and related marks are trademarks of Amazon.com, Inc. or its affiliates. All banking data in examples is fictional. Sample architectures are for learning and are not automatically compliant with GDPR, PCI DSS or any banking regulation.
Amazon SQS in depth
Configure Amazon SQS standard and FIFO queues for banking workloads — visibility timeout, long polling, batching, message groups, deduplication and encryption — and build a production-shaped .NET 10 consumer loop with batch deletes and a visibility heartbeat.
Amazon SNS: fan-out and message filtering
Publish one message to an Amazon SNS topic and deliver it to many consumers: SNS to SQS fan-out, subscription filter policies on attributes and on the message body, delivery retries, subscription dead-letter queues and FIFO topics, with .NET 10 publishers, CDK and Terraform.