Class OnExceptionProcessor

Assembly: redb.Route.dll

The OnException handlers of one scope around a body: handles the failures a per-step
TryCatchProcessor did not, with redelivery (delay, exponential backoff, max attempts).

The handler is chosen as Apache Camel's DefaultExceptionPolicyStrategy chooses it: the failure is walked
from its innermost cause up to the exception that was thrown; a handler of exactly that type wins at once;
otherwise the handler whose type is the nearest ancestor does, the earlier exception of the walk and the earlier
declared handler winning a tie. The smallest distance over the whole chain wins, as in Camel's source: a cause
whose nearest handler is further away loses to the thrown exception's nearer one, even a catch-all. A handler
whose OnWhen is false is passed over. A later handler of the same
type without OnWhen replaces the earlier one.


A route has two such scopes, the route's own handlers inside and the ones shared with other routes (its route
configurations and its builder) outside. The inner one leaves a failure to the outer one when that has a strictly
nearer handler; on a tie the route's own handler wins.

public class OnExceptionProcessor : IProcessor

Inheritance

Object→OnExceptionProcessor

Implements

Properties

Handlers

Gets the registered handlers.

public IReadOnlyList<OnExceptionProcessor.ExceptionHandler> Handlers { get; }

Methods

Handle(Type, IProcessor, int, TimeSpan?, double, bool, bool, bool, Func<IExchange, bool>?, LogLevel, LogLevel, Action<IExchange>?, Func<IExchange, bool>?, Action<IExchange>?, Action<IExchange>?, bool, bool, bool, bool, bool, IProcessor?, IProcessor?, IProcessor?, bool, bool)

Registers a handler for a specific exception type (non-generic).

public OnExceptionProcessor Handle(Type exceptionType, IProcessor handler, int maxRedeliveries = 0, TimeSpan? redeliveryDelay = null, double backoffMultiplier = 1, bool useExponentialBackoff = false, bool handled = false, bool continued = false, Func<IExchange, bool>? onWhenPredicate = null, LogLevel retryAttemptedLogLevel = LogLevel.Warning, LogLevel retriesExhaustedLogLevel = LogLevel.Error, Action<IExchange>? onExceptionOccurred = null, Func<IExchange, bool>? retryWhile = null, Action<IExchange>? onRedelivery = null, Action<IExchange>? onPrepareFailure = null, bool useOriginalMessage = false, bool useOriginalBody = false, bool allowRedeliveryWhileStopping = false, bool logStackTrace = true, bool logExhausted = true, IProcessor? onExceptionOccurredProcessor = null, IProcessor? onRedeliveryProcessor = null, IProcessor? onPrepareFailureProcessor = null, bool logHandled = false, bool logContinued = false)

Handle<TException>(IProcessor, int, TimeSpan?, double, bool, bool, bool, Func<IExchange, bool>?, LogLevel, LogLevel, Action<IExchange>?, Func<IExchange, bool>?, Action<IExchange>?, Action<IExchange>?, bool, bool, bool, bool, bool, bool, bool)

Registers a handler for a specific exception type.

public OnExceptionProcessor Handle<TException>(IProcessor handler, int maxRedeliveries = 0, TimeSpan? redeliveryDelay = null, double backoffMultiplier = 1, bool useExponentialBackoff = false, bool handled = false, bool continued = false, Func<IExchange, bool>? onWhenPredicate = null, LogLevel retryAttemptedLogLevel = LogLevel.Warning, LogLevel retriesExhaustedLogLevel = LogLevel.Error, Action<IExchange>? onExceptionOccurred = null, Func<IExchange, bool>? retryWhile = null, Action<IExchange>? onRedelivery = null, Action<IExchange>? onPrepareFailure = null, bool useOriginalMessage = false, bool useOriginalBody = false, bool allowRedeliveryWhileStopping = false, bool logStackTrace = true, bool logExhausted = true, bool logHandled = false, bool logContinued = false) where TException : Exception

Process(IExchange, CancellationToken)

Processes the exchange asynchronously.

public Task Process(IExchange exchange, CancellationToken ct = default)

Constructors

OnExceptionProcessor(IProcessor, ILogger?)

Creates an on-exception processor wrapping the body.