Skip to content

RetryDelayConfiguration

blehnen edited this page Nov 10, 2026 · 5 revisions

Retry delays

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

For the delay to be respected, the transport must support delayed processing.

A collection of exception types and time spans on the transport configuration controls this behavior. Each time an exception is encountered, the worker records this in the transport. If the count for the exception is exceeded, the message is moved to the error queue. Otherwise, the message is re-processed.

By default, there are no retries. You must set them explicitly.

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

In the example above, an IndexOutOfRangeException is retried 3 times.

You can add multiple exception types. The queue 'walks' the exception types, so you can 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