Question

Difficulty: MediumServerless Development with AWS Lambda

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.)

  1. Set the FunctionResponseTypes parameter to include ReportBatchItemFailures in the Lambda event source mapping.Answer
  2. Return a JSON object from the Lambda function containing a batchItemFailures list with the failed message IDs specified in the itemIdentifier field.Answer
  3. C
    Configure a Dead-Letter Queue (DLQ) directly on the Lambda function configuration to catch individual messages that fail to process within the batch.
  4. D
    Set 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.
  5. E
    Configure 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

1
Configure the SQS event source mapping.
Enable the ReportBatchItemFailures response type on the integration.
This informs Lambda that the function will return a custom structure indicating which specific messages in the batch failed to process.
2
Update the Lambda function return payload.
Return a JSON object structured with a batchItemFailures array containing the failed message IDs in the itemIdentifier field.
This allows AWS Lambda to identify the failed messages, delete the successful messages from the SQS queue, and leave only the failed messages on the queue for retries.

Key Concept

Partial batch response handling in AWS Lambda when integrated with Amazon SQS using event source mappings.
Estimated Time:2m 0s
Rate this question