如何在 .net 中使用过滤策略创建 SNS 订阅?

问题描述 投票:0回答:0

你能帮帮我吗?我正在尝试使用 .net 中的过滤策略通过代码创建对 SNS 的订阅。我的主题具有以下订阅过滤策略(使用 MessageAttribute):

enter image description here

我尝试配置如下:

public async Task CreateSubscriptionAsync()
    {
        using var snsClient = new AmazonSimpleNotificationServiceClient(_amazonSimpleNotificationServiceConfig);

        _ = await snsClient.SubscribeAsync(new SubscribeRequest
        {
            Protocol = "sqs",
            Endpoint = _sqsSettings.Queues!.First(queue => !queue.Consume).Url,
            TopicArn = _snsSettings.Topic!.Arn,
            Attributes = new Dictionary<string, string>() { { "MessageType", "OrderReceived" } }
        });
    }

但是我收到以下错误:

Amazon.SimpleNotificationService.Model.InvalidParameterException : AttributeName.

你能帮帮我吗?

c# .net amazon-web-services amazon-sns
© www.soinside.com 2019 - 2024. All rights reserved.