An application publishes transaction events to an Amazon SNS topic. An Amazon SQS standard queue is subscribed to this topic, and an AWS Lambda function processes messages from the queue. The Lambda function's timeout is configured to seconds. During traffic spikes, some transactions are processed multiple times by different Lambda invocations, causing duplicate database entries. Additionally, the developer wants to ensure that any messages that fail processing times are automatically moved to a dead-letter queue (DLQ).
Which two actions should the developer take to meet these requirements? (Select TWO.)
- Increase the Amazon SQS queue's visibility timeout to at least seconds.Cevap
- Configure a redrive policy on the source Amazon SQS queue specifying a dead-letter queue with a `maxReceiveCount` set to .Cevap
- CConfigure a dead-letter queue target on the AWS Lambda function's asynchronous invocation configuration.
- DDecrease the Amazon SQS queue's visibility timeout to seconds to speed up the recovery of failed messages.
- ESet the Amazon SQS queue's visibility timeout to exactly seconds to align with the Lambda function's timeout.
Cevap
Increase the Amazon SQS queue's visibility timeout to at least seconds and configure a redrive policy on the source Amazon SQS queue with a `maxReceiveCount` set to .
To resolve duplicate processing, the SQS visibility timeout must be configured to at least times the Lambda function's timeout (). This ensures the message remains hidden during execution and potential retries. To redirect failed messages after attempts, a redrive policy with `maxReceiveCount` set to must be configured directly on the source SQS queue because the event source mapping invokes Lambda synchronously.
Adım Adım Çözüm
Anahtar Kavram
Decoupling serverless architectures using Amazon SNS, SQS, and AWS Lambda event source mappings, including proper visibility timeout alignment and redrive policy configuration.