Customizing Error Handling

Component: NServiceBus
NuGet Package: NServiceBus (5.x)
Standard support for version 5.x of NServiceBus has expired. For more information see our Support Policy.

IManageMessageFailures allows custom actions when messages continue to fail after the Immediate Retries have been attempted.

When enabling this extension, second-level retries will not be invoked. Versions 6 and above offer better control of customization through the message pipeline.
public class CustomFaultManager :
    public void SerializationFailedForMessage(TransportMessage message, Exception e)
        // implement steps for this message when the failure is due to deserialization

    public void ProcessingAlwaysFailsForMessage(TransportMessage message, Exception e)
        // implement steps for this message after it fails all Immediate Retry attempts

    public void Init(Address address)
        // implement initializations for the custom fault manager.

This extension must be registered in dependency injection so that it can be invoked when failures occur. Registration of this component can be done using the INeedInitialization interface. See also dependency-injection child lifetime.

    registration: components =>

Related Articles

Last modified