title: Rebus Retry policy
body: <p>I have questions on Rebus retry policy below:</p>
  
  <pre><code>Configure.With(...)
      .Options(b =&gt; b.SimpleRetryStrategy(maxDeliveryAttempts: 2))
      .(...)
  </code></pre>
  
  <p><a href="https://github.com/rebus-org/Rebus/wiki/Automatic-retries-and-error-handling#customizing-retries" rel="nofollow noreferrer">https://github.com/rebus-org/Rebus/wiki/Automatic-retries-and-error-handling#customizing-retries</a></p>
  
  <p>1 Can it be used for both Publiser (enqueue messages) and Subscriber (dequeue messages)?</p>
  
  <p>2 I have a subscriber that is unable to dequeue the message. Thus the message is sent to error queue. </p>
  
  <p>Below is error for when putting the message to error queue. But I cannot see the loggings for the retry.</p>
  
  <pre><code>[ERR] Rebus.Retry.PoisonQueues.PoisonQueueErrorHandler (Thread #9): Moving messa
  ge with ID "&lt;unknown&gt;" to error queue "poison"
  Rebus.Exceptions.RebusApplicationException: Received message with empty or absen
  t 'rbs2-msg-id' header! All messages must be supplied with an ID . If no ID is p
  resent, the message cannot be tracked between delivery attempts, and other stuff
   would also be much harder to do - therefore, it is a requirement that messages
  be supplied with an ID.
  </code></pre>
  
  <p>Is it possible to define and store custom logging for each retry, not within IErrorHandler?</p>
  
  <p>3 How long does each retry wait in between be default? </p>
  
  <p>4 Is it possible to define custom wait time for each retry (not within IErrorHandler)? If so, is Polly supported for this scanario? like below:</p>
  
  <pre><code>Random jitterer = new Random(); 
  Policy
    .Handle&lt;HttpResponseException&gt;() // etc
    .WaitAndRetry(5,    // exponential back-off plus some jitter
        retryAttempt =&gt; TimeSpan.FromSeconds(Math.Pow(2, retryAttempt))  
                      + TimeSpan.FromMilliseconds(jitterer.Next(0, 100)) 
    );
  </code></pre>
  
  <p><a href="https://docs.microsoft.com/en-us/dotnet/standard/microservices-architecture/implement-resilient-applications/implement-http-call-retries-exponential-backoff-polly" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/dotnet/standard/microservices-architecture/implement-resilient-applications/implement-http-call-retries-exponential-backoff-polly</a></p>
  
  <p><strong>Update</strong></p>
  
  <p>How can I test the retry policy?</p>
  
  <p>Below is what I tried based on the code below:</p>
  
  <pre><code>public class StringMessageHandler : IHandleMessages&lt;String&gt;
  {   
      public async Task Handle(String message) 
      {
            //retry logic with Polly here
      }   
  }
  </code></pre>
  
  <p>I sent an invalid message of string type to the string topic, however, the Handle(String message) is not invoked at all.  </p>