Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does Windows Azure Service Bus Queues Duplicate Detection work?

I know that you can set duplicate detection to work over a time period with an azure service bus queue. However, does anyone know whether this works based on the objects in the queue?

So if I have an object with an id of "SO_1" which gets put on the queue and is subsequently consumed, is the duplicate detection still valid?

What I think I'm asking is - is it the timeframe and the object, or just the timeframe that make the queue decide what is a duplicate?

like image 928
Ross Vernal Avatar asked May 31 '13 11:05

Ross Vernal


3 Answers

http://blog.iquestgroup.com/en/windows-azure-service-bus-duplicate-detection/#.UaiXrd7frIU

When we activate duplication, the Windows Azure Service Bus will start to store a history of our messages. This period of time can be configured to range from only a few minutes to days. If a duplicate message is sent to the Service Bus, the service will automatically ignore the message.

like image 123
user2399170 Avatar answered Oct 05 '22 12:10

user2399170


Posting this to clarify on a couple of misconceptions in the responses found above,

  1. Enabling duplicate detection helps keep track of the application-controlled MessageId of all messages sent into a queue or topic during a specified time window. If any new message is sent carrying a MessageId that has already been logged during the time window, the message is reported as accepted (the send operation succeeds), but the newly sent message is instantly ignored and dropped. No other parts of the message other than the MessageId are considered. (the blog referenced in one of the responses says the message content cannot be duplicate which is not correct).

  2. Default value of duplicate detection time history now is 30 seconds, the value can range between 20 seconds and 7 days.

Refer this documentation for more details.

like image 27
Reshma Sulthan Avatar answered Oct 05 '22 13:10

Reshma Sulthan


This actually just bit me, the default seems to be to have it enabled and the default time is 10 minutes. The "key" is the MessageId. In our case, in most scenarios duplicate detection is fine, but in some it was bad news (especially with the 10 minute range). To get around this, we introduced a "breaker":

// For this message, we need to prevent dups from being detected
msg.MessageId = messageId + "_" + DateTime.Now.ToString("u");

If you just want to prevent "spamming" you might consider setting the duplicate detection window to the minimum (20 seconds). (Personally, I would love to see a threshold as low as 5 seconds).

The current ranges allowed are 20 seconds to 7 days.

like image 43
ProVega Avatar answered Oct 05 '22 13:10

ProVega