问题
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