Question

Difficulty: MediumMessage-Based Integration using Amazon SQS and SNS

A developer is implementing an IoT smart-home integration system. Devices publish telemetry and alert events to an Amazon SNS topic. These events must be fanout-routed to 22 separate Amazon SQS queues: one for immediate alarm processing by an AWS Lambda function, and one for daily status archiving. The alarm events require up to 8080 seconds of processing time by the Lambda function, but alarms are currently being processed multiple times by the function. Which actions must the developer take to configure the message routing and prevent duplicate processing of the alarm messages? (Select TWO.)

  1. Configure an Amazon SNS subscription filter policy on the alarm queue's subscription to only accept messages with the 'alarm' attribute.Answer
  2. Increase the visibility timeout of the alarm queue to 9090 seconds to exceed the Lambda function's processing time.Answer
  3. C
    Convert the alarm queue to a FIFO (First-In-First-Out) queue to guarantee that messages are only processed once regardless of processing duration.
  4. D
    Increase the timeout of the Lambda function to 9090 seconds while leaving the alarm queue's visibility timeout at the default 3030 seconds.
  5. E
    Hardcode an IAM Access Key and Secret Key inside the Lambda function's code to authenticate with the Amazon SQS client.

Answer

Configure an Amazon SNS subscription filter policy on the alarm SQS queue's subscription, and increase the visibility timeout of the alarm queue to 9090 seconds.
The correct configurations are setting up an Amazon SNS subscription filter policy and increasing the SQS queue's visibility timeout to 9090 seconds. Subscription filter policies allow the SQS queue to selectively ingest only 'alarm' messages, preventing unnecessary messages from being sent to the queue. Since the processing duration of the Lambda function can take up to 8080 seconds, increasing the SQS visibility timeout to 9090 seconds (which is greater than the 8080-second processing time) ensures that messages remain invisible to other consumers while being processed, avoiding duplicate delivery.

Step-by-Step Solution

1
Configure message routing at the SNS subscription layer.
An SNS subscription filter policy is added to the alarm SQS queue's subscription, ensuring only messages with the attribute set to 'alarm' are forwarded to the queue.
This decouples the system and prevents the alarm processing queue from receiving unrelated status archiving messages.
2
Analyze the cause of duplicate message processing.
Recognize that because the Lambda function takes 8080 seconds to process but the queue's default visibility timeout is 3030 seconds, SQS makes the message visible again before the Lambda function deletes it.
To prevent duplicate delivery, the visibility timeout of the queue must exceed the maximum processing duration of the consumer.
3
Modify the SQS visibility timeout configuration.
The visibility timeout of the SQS queue is increased to 9090 seconds.
This ensures the message remains invisible to other consumers until the Lambda function completes its 8080-second execution and deletes the message.

Key Concept

Decoupling message-based integrations using SNS subscription filter policies and managing SQS visibility timeouts to prevent duplicate processing.
Rate this question