Skip to content

Commit d04efbc

Browse files
TCBroadbarclayadam
authored andcommitted
Added configurable setting for duplicate detection, as it is a premium tier option
1 parent 29264fb commit d04efbc

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

src/HangFire.Azure.ServiceBusQueue/ServiceBusManager.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,11 @@ private static void CreateQueueIfNotExists(string prefixedQueue, NamespaceManage
8787

8888
Logger.InfoFormat("Creating new queue {0}", prefixedQueue);
8989

90-
var description = new QueueDescription(prefixedQueue)
90+
var description = new QueueDescription(prefixedQueue);
91+
if (options.RequiresDuplicateDetection != null)
9192
{
92-
RequiresDuplicateDetection = true
93-
};
93+
description.RequiresDuplicateDetection = options.RequiresDuplicateDetection.Value;
94+
}
9495

9596
if (options.Configure != null)
9697
{

src/HangFire.Azure.ServiceBusQueue/ServiceBusQueueOptions.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,17 @@ public ServiceBusQueueOptions()
4040

4141
public string[] Queues { get; set; }
4242

43+
/// <summary>
44+
/// Gets or sets a value which specifies the <see cref="Microsoft.ServiceBus.Messaging.QueueDescription.RequiresDuplicateDetection"/>
45+
/// setting on creating a service bus queue.
46+
/// </summary>
47+
/// <remarks>
48+
/// <para>This can provide resilience against retried messages due to transient errors within Hangfire, but will not help
49+
/// with application-level issues.</para>
50+
/// <para>This setting can only be applied to premium tier namespace, leave null if using a standard tier namespace.</para>
51+
/// </remarks>
52+
public bool? RequiresDuplicateDetection { get; set; }
53+
4354
/// <summary>
4455
/// Gets or sets a timeout that is used between loop runs of receiving messages from Azure Service Bus. This is the timeout
4556
/// used when waiting on the last queue before looping around again (does not apply when only a single-queue exists).

0 commit comments

Comments
 (0)