AWS
SQS
SNS
troubleshooting
message-delivery

AWS SQS not receiving SNS messages

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

AWS SQS Not Receiving SNS Messages

Amazon Web Services (AWS) provides a comprehensive suite of cloud computing services, among which Simple Notification Service (SNS) and Simple Queue Service (SQS) are prominent for building decoupled, distributed systems. While both services are robust and reliable, sometimes developers encounter scenarios where an SQS queue doesn't receive messages from SNS. This article delves into potential reasons and solutions for this issue.

Architecture Overview

  • Amazon SNS: A fully managed push notification service that allows you to decouple microservices, distributed systems, and serverless applications. It uses topics to categorize and distribute messages to subscribers, which could be HTTP(S) endpoints, Lambda functions, email addresses, or SQS queues.
  • Amazon SQS: A fully managed message queuing service that enables you to decouple and scale microservices, distributed systems, and serverless applications. SQS ensures that messages are delivered once and are available until a consumer processes and deletes them.

Causes and Troubleshooting

1. Subscription Confirmation Issues

  • Problem: SNS requires subscriptions to be confirmed before it starts sending messages. If a subscription to an SQS is not confirmed, no messages will be sent to the queue.
  • Solution: Check the subscription status in the SNS console. If it's in a "PendingConfirmation" state, manually confirm it using the AWS Management Console or the AWS CLI.

2. IAM Policies and Permissions

  • Problem: Incorrectly configured Identity and Access Management (IAM) policies can prevent SNS from delivering messages to SQS.
  • Solution: Ensure that the correct IAM policies are attached. SNS needs SendMessage permission on the SQS queue. You can attach the following policy to your SQS:
  • Problem: Misconfigured settings during the creation of the subscription between SNS and SQS.
  • Solution: When you subscribe an SQS queue to an SNS topic, ensure you select the correct queue. Double-check the ARN references for both SNS and SQS in the subscription details.
  • Problem: SNS message format discrepancies can sometimes lead to delivery issues, especially with attributes or larger payloads that might not be correctly handled by SQS.
  • Solution: Examine and, if necessary, limit the message attributes or size. Ensure that SNS message attributes conform to the limits of SQS.
  • Problem: Message throttling and retention settings might lead to messages not being delivered or stored correctly.
  • Solution: Verify the message throughput levels and adjust the queue's settings for retention period. Note that standard queues offer unlimited throughput, but you must ensure the configured retention period suits your application.

Course illustration
Course illustration

All Rights Reserved.