AWS SDK Version 2 for .NET
API Reference

AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.

.NET Framework 4.5
 
Subscribes an existing Amazon SQS queue to existing Amazon SNS topics.

The policy applied to the SQS queue is similar to this:

{
    "Version" : "2008-10-17",
    "Statement" : [{
        "Sid" : "topic-subscription-arn:aws:sns:us-west-2:599109622955:myTopic",
        "Effect" : "Allow",
        "Principal" : "*",
        "Action" : ["sqs:SendMessage"],
        "Resource":["arn:aws:sqs:us-west-2:599109622955:myQueue"],
        "Condition" : {
            "ArnLike":{
                "aws:SourceArn":["arn:aws:sns:us-west-2:599109622955:myTopic"]
            }
        }
    }]
}
            

There might be a small time period immediately after subscribing the SQS queue to the SNS topic and updating the SQS queue's policy, where messages are not able to be delivered to the queue. After a moment, the new queue policy will propagate and the queue will be able to receive messages. This delay only occurs immediately after initially subscribing the queue.

Namespace: Amazon.SimpleNotificationService
Assembly: AWSSDK.dll
Version: (assembly version)

Syntax

C#
public IDictionary<String, String> SubscribeQueueToTopics(
         IList<String> topicArns,
         IAmazonSQS sqsClient,
         String sqsQueueUrl
)

Parameters

topicArns
Type: IList<System.String>

The topics to subscribe to

sqsClient
Type: Amazon.SQS.IAmazonSQS

The SQS client used to get attributes and set the policy on the SQS queue.

sqsQueueUrl
Type: System.String

The queue to add a subscription to.

Return Value
IDictionary<System.String, System.String> The mapping of topic ARNs to subscription ARNs as returned by Amazon SNS when the queue is successfully subscribed to each topic.

Version Information

.NET Framework:
Supported in: 4.5, 4.0, 3.5