1

I have questions on Backoff policy below:

1 Can it be used for both Publiser (enqueue messages) and Subscriber (dequeue messages)?

2 Is Rebus Backoff policy same as Polly's Retry? But the description below mentions idle time, which I am a bit confused.

   //
    // Summary:
    //     Configures the timespans to wait when backing off polling the transport during
    //     idle times. backoffTimes must be a sequence of timespans, which indicates the
    //     time to wait for each second elapsed being idle. When the idle time exceeds the
    //     number of timespans, the last timespan will be used.
    public static void SetBackoffTimes(this OptionsConfigurer configurer, params TimeSpan[] backoffTimes);



Configure.With(...)
    .(...)
    .Options(o => {
        o.SetBackoffTimes(
            TimeSpan.FromMilliseconds(100),
            TimeSpan.FromMilliseconds(200),
            TimeSpan.FromSeconds(1)
        );
    })
            .Start();

3 Does Rebus support Polly extension? For example, exponential back-off plus some jitter like at the bottom

Random jitterer = new Random(); 
Policy
  .Handle<HttpResponseException>() // etc
  .WaitAndRetry(5,    // exponential back-off plus some jitter
      retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt))  
                    + TimeSpan.FromMilliseconds(jitterer.Next(0, 100)) 
  );

https://learn.microsoft.com/en-us/dotnet/standard/microservices-architecture/implement-resilient-applications/implement-http-call-retries-exponential-backoff-polly

4 I cannot find ISyncBackoffStrategy on the latest Rebus nutget. Is it deprecated?

 Configure.With(...)
        .(...)
        .Options(o => {
            o.Register<ISyncBackoffStrategy>(c => {
                var strategy = new MyOwnBackoffStrategy();
                return strategy;
            });
        })
        .Start();

https://github.com/rebus-org/Rebus/wiki/Back-off-strategy

Pingpong
  • 7,681
  • 21
  • 83
  • 209

1 Answers1

2

Rebus' backoff strategy is used only by a message consumer, so it can relax while there is less work to do.

It's not about RETRY, it's more about being easy on the CPU in quiet times.

The term "idle time" in the documentation simply means "time, where no messages have been received". So, as long as there's messages in the queue, Rebus will process messages as fast as you can handle them, but if suddenly the queue is empty, then it will gradually poll less and less frequently.

You can implement your own backoff strategy by implementing IBackoffStrategy (that's what it's called now, I've updated the wiki accordingly).

mookid8000
  • 18,258
  • 2
  • 39
  • 63
  • Thanks. IBackoffStrategy is more about idle time as you mentioned. This is different from what the "back off" strategy is in my mind , as showed on question 3. It refers to when there is error in processing, and back off kicks in. In this case, what is the solution from Rebus? Polly is good at this scenario, is it supported in Rebus? – Pingpong May 16 '19 at 11:01