Reputation: 8009
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))
);
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
Upvotes: 1
Views: 528
Reputation: 18628
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).
Upvotes: 2