3

SQS キューに行くように Amazon Ses 通知をセットアップしようとしています。SQS キューを作成してから SNS トピックを作成し、一方を他方にサブスクライブする方法の指示に従っています。

ただし、管理コンソールでは、サブスクリプションは「保留中の確認」と表示されます。

.NET AWS SDK を使用していますが、サブスクリプションを確認するにはどうすればよいですか? またはさらに良いことに、なぜ確認する必要があるのですか? ドキュメントによると

キューの所有者がサブスクリプションを作成すると、サブスクリプションは自動的に確認され、サブスクリプションはすぐにアクティブになります。

すべての API 呼び出しに所有者として AWS 資格情報を使用しているため、確認する必要がある理由がわかりませんが、とにかくどうすればよいですか?

    private static string CreateBounceTopicAndQueue(IAmazonSQS sqsClient, IAmazonSimpleNotificationService snsClient)
    {
        // 1. Create an Amazon SQS queue named ses-bounces-queue.
        CreateQueueResponse createQueueResponse = sqsClient.CreateQueue(new CreateQueueRequest()
        {
            QueueName = AppGlobal.SesBouncesQueue,
            Attributes = new Dictionary<string, string>() {
                { "ReceiveMessageWaitTimeSeconds", "20" }
            }
        });
        string queueUrl = createQueueResponse.QueueUrl;

        // 2. Create an Amazon SNS topic named ses-bounces-topic
        CreateTopicResponse createTopicResponse = snsClient.CreateTopic(new CreateTopicRequest
        {
            Name = AppGlobal.SesBouncesTopic
        });
        string topicArn = createTopicResponse.TopicArn;

        // 3. Configure the Amazon SNS topic to publish to the SQS queue
        var response =  snsClient.Subscribe(new SubscribeRequest
        {
            TopicArn = topicArn,
            Endpoint = queueUrl,
            Protocol = "https"
        });

        return queueUrl;
    }
4

1 に答える 1

1

キュー URL を使用して https サブスクリプションを作成することによって、SQS キューを SNS トピックにサブスクライブしません。

エンドポイントとしてキューのARN (Web エンドポイントではない) を使用して、" sqs " (https ではない) プロトコル サブスクリプションを作成します。


protocol
Type: System.String
The protocol you want to use. 
...
sqs -- delivery of JSON-encoded message to an Amazon SQS queue

endpoint
Type: System.String
The endpoint that you want to receive notifications. Endpoints vary by protocol...

For the sqs protocol, the endpoint is the ARN of an Amazon SQS queue

http://docs.aws.amazon.com/sdkfornet/latest/apidocs/items/MSNS_SNSSubscribe_String_String_StringNET4_5.html

于 2014-10-16T05:04:40.937 に答える