无法使用NService Bus设置Amazon SQ中每个队列的默认标签

发布于 2025-01-18 15:38:13 字数 1916 浏览 2 评论 0原文

目前,我必须将我们的消息系统切换为使用 AmazonSQS,并且由于定价政策,我们有义务放置标签。但我没有找到任何添加标签的方法。

下面的方法不起作用,因为该方法期望队列已经存在并且我可以获取队列的 URL:

public static EndpointConfiguration CreateEndpointConfiguration(BusConfig config)
    {
        var endpointConfiguration = new EndpointConfiguration(config.QueueName);

        endpointConfiguration.LicensePath("license.xml");
        endpointConfiguration.SendFailedMessagesTo($"{config.QueueName}.Errors");
        endpointConfiguration.EnableInstallers();
        endpointConfiguration.UseSerialization<NewtonsoftSerializer>();
        endpointConfiguration.LimitMessageProcessingConcurrencyTo(10);

        endpointConfiguration.Conventions()
                             .DefiningEventsAs(type => typeof(IMessage).IsAssignableFrom(type))
                             .DefiningCommandsAs(type => typeof(ICommand).IsAssignableFrom(type));

        var transport = endpointConfiguration.UseTransport<SqsTransport>();
        transport.ClientFactory(() =>
        {
            var amazonSQSConfig = new AmazonSQSConfig()
            {
                RegionEndpoint = RegionEndpoint.USWest2
            };
            var client = new AmazonSQSClient(amazonSQSConfig);
            
            var addedTags = new Dictionary<string, string>();
            addedTags.Add("Team", "Development");
            addedTags.Add("Accounting ID", "number");

            var tagQueueRequest = new TagQueueRequest()
            {
                Tags = addedTags
            };

            client.TagQueueAsync(tagQueueRequest);
            
            return client;
        });
        transport.QueueNamePrefix("some-prefix");
        
        endpointConfiguration.Recoverability()
                             .AddUnrecoverableException<CustomException>();

        return endpointConfiguration;
    }

您能否提供在配置端点期间自动添加标签的解决方案? 感谢您的帮助

Currently, I have to switch our messaging system to use AmazonSQS and due to pricing policy, we are obliged to put tags. But I do not found any method to add tags.

Below the method which won't work due to fact that this approach is expecting that the queues already exist and I can get URL of the queue:

public static EndpointConfiguration CreateEndpointConfiguration(BusConfig config)
    {
        var endpointConfiguration = new EndpointConfiguration(config.QueueName);

        endpointConfiguration.LicensePath("license.xml");
        endpointConfiguration.SendFailedMessagesTo(
quot;{config.QueueName}.Errors");
        endpointConfiguration.EnableInstallers();
        endpointConfiguration.UseSerialization<NewtonsoftSerializer>();
        endpointConfiguration.LimitMessageProcessingConcurrencyTo(10);

        endpointConfiguration.Conventions()
                             .DefiningEventsAs(type => typeof(IMessage).IsAssignableFrom(type))
                             .DefiningCommandsAs(type => typeof(ICommand).IsAssignableFrom(type));

        var transport = endpointConfiguration.UseTransport<SqsTransport>();
        transport.ClientFactory(() =>
        {
            var amazonSQSConfig = new AmazonSQSConfig()
            {
                RegionEndpoint = RegionEndpoint.USWest2
            };
            var client = new AmazonSQSClient(amazonSQSConfig);
            
            var addedTags = new Dictionary<string, string>();
            addedTags.Add("Team", "Development");
            addedTags.Add("Accounting ID", "number");

            var tagQueueRequest = new TagQueueRequest()
            {
                Tags = addedTags
            };

            client.TagQueueAsync(tagQueueRequest);
            
            return client;
        });
        transport.QueueNamePrefix("some-prefix");
        
        endpointConfiguration.Recoverability()
                             .AddUnrecoverableException<CustomException>();

        return endpointConfiguration;
    }

Can you provide solution for adding automatically tags during configuring endpoints?
Thank you for any help

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

帝王念 2025-01-25 15:38:13

NServiceBus 与 SQS 集成 目前似乎不支持标签配置。您必须使用适当的标签预先手动创建队列,或者手动 将标签添加到现有队列

您可以在此处针对特定软件的 SQS 传输存储库提出标签支持的功能请求:https://github.com/特别/NServiceBus.AmazonSQS

The NServiceBus integration with SQS doesn't seem to support configuration of tags at the moment. You'd have to manually create your queues upfront with the appropriate tags or manually add tags to existing queues.

You can raise feature requests for tag support on Particular Software's SQS transport repository here: https://github.com/Particular/NServiceBus.AmazonSQS

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文