From d04efbc03f804bde6606010eb640d52d7a16f446 Mon Sep 17 00:00:00 2001 From: Tom Broad Date: Wed, 7 Nov 2018 14:18:31 +0000 Subject: [PATCH] Added configurable setting for duplicate detection, as it is a premium tier option --- .../ServiceBusManager.cs | 7 ++++--- .../ServiceBusQueueOptions.cs | 11 +++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/HangFire.Azure.ServiceBusQueue/ServiceBusManager.cs b/src/HangFire.Azure.ServiceBusQueue/ServiceBusManager.cs index 2fe2138..bc67f7b 100644 --- a/src/HangFire.Azure.ServiceBusQueue/ServiceBusManager.cs +++ b/src/HangFire.Azure.ServiceBusQueue/ServiceBusManager.cs @@ -87,10 +87,11 @@ private static void CreateQueueIfNotExists(string prefixedQueue, NamespaceManage Logger.InfoFormat("Creating new queue {0}", prefixedQueue); - var description = new QueueDescription(prefixedQueue) + var description = new QueueDescription(prefixedQueue); + if (options.RequiresDuplicateDetection != null) { - RequiresDuplicateDetection = true - }; + description.RequiresDuplicateDetection = options.RequiresDuplicateDetection.Value; + } if (options.Configure != null) { diff --git a/src/HangFire.Azure.ServiceBusQueue/ServiceBusQueueOptions.cs b/src/HangFire.Azure.ServiceBusQueue/ServiceBusQueueOptions.cs index 7c6ca54..7902ed6 100644 --- a/src/HangFire.Azure.ServiceBusQueue/ServiceBusQueueOptions.cs +++ b/src/HangFire.Azure.ServiceBusQueue/ServiceBusQueueOptions.cs @@ -40,6 +40,17 @@ public ServiceBusQueueOptions() public string[] Queues { get; set; } + /// + /// Gets or sets a value which specifies the + /// setting on creating a service bus queue. + /// + /// + /// This can provide resilience against retried messages due to transient errors within Hangfire, but will not help + /// with application-level issues. + /// This setting can only be applied to premium tier namespace, leave null if using a standard tier namespace. + /// + public bool? RequiresDuplicateDetection { get; set; } + /// /// Gets or sets a timeout that is used between loop runs of receiving messages from Azure Service Bus. This is the timeout /// used when waiting on the last queue before looping around again (does not apply when only a single-queue exists).