A developer is designing a serverless application where an Amazon SQS queue triggers an AWS Lambda function to process customer orders in batches. During peak traffic, some orders fail to process due to downstream database locks. To prevent successful messages in a batch from being returned to the queue and reprocessed, the developer wants to enable partial batch response handling. Which combination of actions should the developer take to achieve this behavior? (Select TWO.)
- Set the FunctionResponseTypes parameter to include ReportBatchItemFailures in the Lambda event source mapping.Answer
- Return a JSON object from the Lambda function containing a batchItemFailures list with the failed message IDs specified in the itemIdentifier field.Answer
- CConfigure a Dead-Letter Queue (DLQ) directly on the Lambda function configuration to catch individual messages that fail to process within the batch.
- DSet the visibility timeout of the SQS queue to be shorter than the Lambda function's execution timeout to allow failed messages to be retried immediately.
- EConfigure an Amazon API Gateway Lambda Proxy integration to intercept and filter out the failed messages before they are processed by the Lambda function.
Answer
To configure partial batch response handling, the developer must set the FunctionResponseTypes parameter to include ReportBatchItemFailures in the Lambda event source mapping, and the Lambda function must return a JSON object containing a batchItemFailures list with the failed message IDs in the itemIdentifier field.
To achieve partial batch response handling, the event source mapping must be configured to report batch item failures. The Lambda function must then return a JSON object with a list named batchItemFailures. Inside this list, each failed message is represented by an object with its message ID stored under the itemIdentifier key. SQS will automatically delete all successfully processed messages from the queue and make only the failed messages visible again.
Step-by-Step Solution
Key Concept
Partial batch response handling in AWS Lambda when integrated with Amazon SQS using event source mappings.
Estimated Time:2m 0s