Soru

Zorluk: Çok zorMessage-Based Integration using Amazon SQS and SNS

An enterprise transaction processing application uses a decoupled architecture where a core system publishes high-priority financial transaction messages to an Amazon SNS FIFO topic. Two downstream services consume these messages:

- Service A: Runs on AWS Lambda, consumes messages via an Amazon SQS FIFO queue subscribed to the SNS FIFO topic, and updates account balances in an Amazon DynamoDB table. The Lambda function has a maximum concurrency of 5 and can take up to 20 seconds to process a batch of messages.
- Service B: Runs on Amazon ECS Fargate and consumes messages via a separate Amazon SQS FIFO queue subscribed to the SNS FIFO topic for audit logging.

During peak transaction hours, the developer observes two issues:
1. Service A experiences occasional transaction processing failures due to DynamoDB ProvisionedThroughputExceededException. The developer wants to retry only the failed transactions within a batch rather than reprocessing the entire batch, while maintaining the processing order of the remaining messages.
2. Service B occasionally processes duplicate transaction logs. This happens because the publishing system retries sending messages to the SNS FIFO topic when it encounters temporary network timeouts before receiving a publish acknowledgment from SNS.

Which two actions should the developer take to resolve these issues? (Select TWO.)

  1. Configure the Lambda event source mapping for Service A with ReportBatchItemFailures enabled, and modify the Lambda function code to return the message IDs of the failed transactions in a batchItemFailures array.Cevap
  2. Configure the publisher application to generate a consistent MessageDeduplicationId based on the unique transaction ID for each SNS FIFO publish request.Cevap
  3. C
    Configure the SQS FIFO queue for Service A with a visibility timeout that is shorter than the Lambda function timeout to ensure that failed messages are retried immediately by another Lambda container.
  4. D
    Modify the Lambda function for Service A to catch the ProvisionedThroughputExceededException and sleep until the function times out, allowing the SQS visibility timeout to naturally expire and retry the entire batch.
  5. E
    Replace the SQS FIFO queue for Service A with a DynamoDB Streams consumer, and query the stream using a Scan operation to find and retry only the failed transactions.

Cevap

To resolve the issues, the developer should configure the Lambda event source mapping for Service A with ReportBatchItemFailures enabled and modify the Lambda function code to return the message IDs of the failed transactions in a batchItemFailures array. Additionally, they should configure the publisher application to generate a consistent MessageDeduplicationId based on the unique transaction ID for each SNS FIFO publish request.
The correct solution uses partial batch responses and publisher deduplication. By enabling ReportBatchItemFailures on the SQS event source mapping and returning the failed transaction message IDs in the batchItemFailures array, the developer prevents successful messages from being retried while allowing SQS FIFO to maintain ordering. Additionally, by setting a consistent MessageDeduplicationId based on the transaction ID on the SNS FIFO topic, the publisher ensures that network retry attempts are deduplicated by SNS before reaching the downstream SQS FIFO queues.

Adım Adım Çözüm

1
Address partial batch failures in Service A by enabling ReportBatchItemFailures.
This configures the Lambda event source mapping to accept partial batch success responses.
This allows SQS to retry only the failed items in the batch rather than the entire batch, maintaining strict FIFO order for the remaining messages.
2
Update the Service A Lambda function code response format.
The function now returns a JSON payload containing the batchItemFailures array populated with the messageId of each failed message.
This tells the SQS poller exactly which messages failed processing so only those are returned to the queue.
3
Mitigate publisher retries causing duplicates in Service B by implementing deduplication at the source.
The publishing system supplies a consistent MessageDeduplicationId based on the business transaction ID to the SNS FIFO topic.
SNS FIFO uses this ID to deduplicate retry attempts within a 5-minute window, ensuring only one unique message is delivered to the subscribed SQS queues.

Anahtar Kavram

Handling partial batch failures in SQS FIFO queues with AWS Lambda and deduplicating retries in Amazon SNS FIFO using MessageDeduplicationId.
Tahmini Süre:3m 0s
Bu soruyu puanla