AWS Certified Solutions Architect Decoupling with SQS and SNS 2 — Questions and Answers
Question 1: A company wants to ensure that messages in an SQS queue are not processed more than once. Which SQS queue type and feature should be used?
- Standard queue with message deduplication ID
- FIFO queue with content-based deduplication enabled (Correct answer)
- Standard queue with visibility timeout set to 0
- FIFO queue with long polling enabled
Correct answer: FIFO queue with content-based deduplication enabled
FIFO queues with content-based deduplication use a SHA-256 hash of the message body to prevent duplicate messages within a 5-minute deduplication interval.
Question 2: An SNS topic is configured to deliver messages to an SQS queue. The SQS queue policy must allow which principal to send messages?
- The IAM user who created the SNS topic
- The SNS service (sns.amazonaws.com) (Correct answer)
- The AWS account root user
- The Lambda function subscribed to the topic
Correct answer: The SNS service (sns.amazonaws.com)
The SQS queue resource policy must grant the SNS service principal (sns.amazonaws.com) permission to send messages to the queue.
Question 3: A solutions architect needs messages to be delivered in strict order to multiple SQS consumers. Which combination achieves this?
- Standard SQS queue with multiple consumers using long polling
- FIFO SQS queue with a single consumer group per message group ID (Correct answer)
- Standard SQS queue with a DLQ for ordering failures
- FIFO SQS queue with content-based deduplication and multiple consumers reading the same message group
Correct answer: FIFO SQS queue with a single consumer group per message group ID
Within a FIFO queue, messages with the same MessageGroupId are delivered in order, and only one consumer processes messages from a given group at a time.
Question 4: What happens to an SQS message when a consumer receives it but does not delete it before the visibility timeout expires?
- The message is permanently deleted from the queue
- The message is moved to the dead-letter queue automatically
- The message becomes visible again and can be received by another consumer (Correct answer)
- The message is archived in S3 for later processing
Correct answer: The message becomes visible again and can be received by another consumer
After the visibility timeout expires without deletion, SQS makes the message visible again so another consumer can attempt to process it.
Question 5: A company uses SNS fan-out to deliver order events to multiple SQS queues. One downstream team needs to receive only 'CANCELLED' order events. What is the correct approach?
- Create a separate SNS topic exclusively for cancellations
- Apply an SNS subscription filter policy on the team's SQS subscription (Correct answer)
- Use SQS message filtering on the receiving queue
- Configure CloudWatch Events to route messages by attribute
Correct answer: Apply an SNS subscription filter policy on the team's SQS subscription
SNS subscription filter policies allow each subscriber to receive only messages whose attributes match defined criteria, such as orderStatus = CANCELLED.
Question 6: What is the maximum message size supported by Amazon SQS?
- 64 KB
- 256 KB (Correct answer)
- 1 MB
- 10 MB
Correct answer: 256 KB
Amazon SQS supports a maximum message size of 256 KB; larger payloads must be stored in S3 and referenced via the SQS Extended Client Library.
Question 7: Which SQS feature allows a consumer to retrieve up to 10 messages in a single API call, reducing the number of empty responses when the queue is sparse?
- Short polling with WaitTimeSeconds=0
- Long polling with WaitTimeSeconds up to 20 (Correct answer)
- Batch receive with MaxNumberOfMessages=10
- Dead-letter queue redrive policy
Correct answer: Long polling with WaitTimeSeconds up to 20
Long polling keeps the connection open for up to 20 seconds and returns as soon as a message arrives, reducing empty responses and API costs.
A company wants to ensure that messages in an SQS queue are not processed more than once.
Which SQS queue type and feature should be used?