How to configure the RequiresDuplicateDetection for AzureServiceBus topics

ⅰ亾dé卋堺 提交于 2021-02-11 07:41:08

问题


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;
        });

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.


回答1:


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.

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



来源:https://stackoverflow.com/questions/63599575/how-to-configure-the-requiresduplicatedetection-for-azureservicebus-topics

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!