AWS
SNS
SQS
Message Queue
Cloud Troubleshooting

SNS topic not publishing to SQS

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

Introduction

Amazon Simple Notification Service (SNS) is a fully-managed messaging service that is widely used to decouple and fan out microservices, distributed systems, and serverless applications. One common use case of SNS is to publish messages to Amazon Simple Queue Service (SQS) for further processing. However, at times, you might encounter issues where SNS messages are not being published to SQS as expected. This article delves into the technical reasons why this issue might occur and provides solutions to resolve it.

Key Concepts

Before addressing the problem, it's critical to understand the fundamental workings of SNS and SQS.

Amazon SNS

  • Topic: A channel that messages are published to, and which subscribers can subscribe to.
  • Policy: Controls who can publish messages to the topic and how they can be consumed.

Amazon SQS

  • Queue: A service that stores messages for processing and delivery.
  • Access Policy: Determines who can send messages to and receive messages from the queue.

Potential Causes and Solutions

If SNS fails to publish messages to SQS, it could be due to various reasons, including configuration errors and permission issues. Below, we explore common causes along with their solutions:

1. Permission Issues

Problem

A common cause is insufficient permissions configured in SNS Topic Policy or SQS Queue Policy.

Solution

  • Update SNS Topic Policy: Ensure that your SNS topic has the necessary permissions to send messages to the SQS queue.
  • Update SQS Queue Policy: Make sure that the SQS queue allows receiving messages from the SNS topic.
  • Validate Subscription: Ensure that the SNS subscription is correctly pointing to the SQS queue and that the subscription is confirmed.
  • Check Configuration: Verify that the correct Queue URL and ARN are used in the configuration.
  • Monitor Service Health: Use AWS CloudWatch to monitor SNS and SQS metrics for any anomalies or errors.
  • Check AWS Service Status: Regularly check the AWS Service Health Dashboard for any reported outage or degradation in service.
  • Optimize Message Size: Ensure that the message size does not exceed the allowed limits. For SNS, the maximum is usually 256 KB (before base64 encoding).

Related reading
Course
Beginner
27 lessons
10 hours
System Design Fundamentals

Build a strong foundation in designing scalable, reliable distributed systems.

View the course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

All Rights Reserved.