如何为AzureServiceBus配置RequiresDuplicateDetection主题 [英] How to configure the RequiresDuplicateDetection for AzureServiceBus topics

查看:52
本文介绍了如何为AzureServiceBus配置RequiresDuplicateDetection主题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将 ASB 主题的 RequiresDuplicateDetection 属性配置为 true,但似乎没有遵守主 IServiceBusFactoryConfigurator 上的设置:

I am trying to configure the RequiresDuplicateDetection property on the ASB topics to true, but it doesn't appear that the setting on the main IServiceBusFactoryConfigurator is respected:

        var busControl = Bus.Factory.CreateUsingAzureServiceBus(cfg =>
        {
            cfg.Host("ASB_ConnectionString");
            cfg.SubscriptionEndpoint<ExtractionRequest>("Test", e =>
            {
                e.LockDuration = TimeSpan.FromMinutes(1);
                e.MaxAutoRenewDuration = TimeSpan.FromMinutes(5);
                e.AutoDeleteOnIdle = TimeSpan.FromHours(1);
            });
            cfg.RequiresDuplicateDetection = true;
        });

在ASB上为此订阅创建的任何主题似乎都不符合该设置.我发现了一种(可能很怪异)的解决方法,方法是钩住我消息类型的 PublishTopology 上的 TopicDescription 对象.

Any topics that are created for this subscription on ASB don't seem to respect the setting. I found a (maybe hacky) way to actually work around by hooking into the TopicDescription object on the PublishTopology of my message type.

        var smth = busControl.Topology.Publish<ExtractionRequest>() as ServiceBusMessagePublishTopology<ExtractionRequest>;
        smth.TopicDescription.RequiresDuplicateDetection = true;

此替代方法后正确创建的主题.如果任何人都可以对此有所了解,那就太好了.

The topics that are created correctly after this workaround. If anyone can shed some light on this, that would be great.

推荐答案

您可以在总线配置器中配置主题的发布拓扑:

You can configure the publish topology for the topic within the bus configurator:

cfg.Publish<ExtractionRequest>(x => x.RequiresDuplicateDetection = true);

您应先配置拓扑,然后再配置订阅端点,在这种情况下,订购尤为重要.

You should configure the topology prior to configuring your subscription endpoint, order matters particularly in this case.

在您的示例中,指定 cfg.RequiresDuplicateDetection = true; 仅配置总线接收终结点,而不配置订阅终结点或任何其他已配置的接收终结点.

In your example, specifying cfg.RequiresDuplicateDetection = true; configures the bus receive endpoint only, not the subscription endpoint or any other configured receive endpoints.

这篇关于如何为AzureServiceBus配置RequiresDuplicateDetection主题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆