Skip to content

RetryDelayConfiguration

Brian Lehnen edited this page Nov 1, 2015 · 2 revisions

Retry delays

When a worker encounters an exception in user code, it can be configured to retry the message later, based on the exception type.

Note that for the delay to be respected, the transport must support delayed processing.

This is controlled by a collection of exception types and timestamps on the transport configuration. Each time an is encountered, the worker will record this in the transport. If the count for the exception has been exceeded, the message will be moved to the error queue. Otherwise, the message will be re-processed.

By default, there will be no retries. You'll need to explictly set them.

var list = new List<TimeSpan>
{
	TimeSpan.FromSeconds(1),
    TimeSpan.FromSeconds(2),
    TimeSpan.FromSeconds(30)
};
queue.Configuration.TransportConfiguration.RetryDelayBehavior.Add(typeof (IndexOutOfRangeException), list);

In the above example, an exception of IndexOutOfRangeException will be re-tried 3 times.

You can add multiple exception types. The queue will 'walk' the exception types, allowing you to nest them. For instance

queue.Configuration.TransportConfiguration.RetryDelayBehavior.Add(typeof (Exception), list);

would act as a catch-all, but only if the thrown exception did not match a different behavior first.

Clone this wiki locally