title: How to use Azure Service Bus Queue Duplicate Detection only on waiting messages?
body: <p>We are going to leverage the Azure Service Bus Queue to dispatch messages that trigger an expensive database calculation. These messages can be generated fairly rapidly, and there are instances where the same messages can be generated close together. In this case, we only want to process the data once.</p>
  
  <p>So we intend on leveraging Duplicate Detection, but there are some nuances that I cannot glean from the documentation or from previous questions. The parameters are:</p>
  
  <ol>
  <li>If a message is waiting to be processed, and an identical message is about to be created, <strong>DON'T</strong> create it.</li>
  <li>If a message was processed previously, and an identical message is about to be created, <strong>DO</strong> create it. </li>
  <li>If a message is currently being processed, and an identical message is about to be created, <strong>DO</strong> create it.</li>
  </ol>
  
  <p>What I can't find out is a way to disable "historical" duplicate detection but enable "waiting" duplicate detection - detect messages waiting in the queue but not those that have already been processed. Does the Duplicate detection history mechanism work only on completed messages or is the timeframe also relevant to waiting messages relative to each other?</p>
  
  <p>For #3, I am considering solving that by adding a 5 minute delay to processing any message, so that if one is created while one is processing, there is enough time for the processing one to complete. </p>