Show / Hide Table of Contents

    Class ErrorPolicyImplementation

    An error policy is used to handle errors that may occur while processing the inbound messages.

    Inheritance
    object
    ErrorPolicyImplementation
    Implements
    IErrorPolicyImplementation
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Silverback.Messaging.Inbound.ErrorHandling
    Assembly: Silverback.Integration.dll
    Syntax
    public abstract class ErrorPolicyImplementation : IErrorPolicyImplementation

    Constructors

    | Improve this doc View source

    ErrorPolicyImplementation(int?, ICollection<Type>, ICollection<Type>, Func<IRawInboundEnvelope, Exception, bool>?, Func<IRawInboundEnvelope, Exception, object?>?, IServiceProvider, IInboundLogger<ErrorPolicyBase>)

    Initializes a new instance of the ErrorPolicyImplementation class.

    Declaration
    protected ErrorPolicyImplementation(int? maxFailedAttempts, ICollection<Type> excludedExceptions, ICollection<Type> includedExceptions, Func<IRawInboundEnvelope, Exception, bool>? applyRule, Func<IRawInboundEnvelope, Exception, object?>? messageToPublishFactory, IServiceProvider serviceProvider, IInboundLogger<ErrorPolicyBase> logger)
    Parameters
    Type Name Description
    int? maxFailedAttempts

    The number of times this policy should be applied to the same message in case of multiple failed attempts.

    ICollection<Type> excludedExceptions

    The collection of exception types this policy doesn't have to be applied to.

    ICollection<Type> includedExceptions

    The collection of exception types this policy have to be applied to.

    Func<IRawInboundEnvelope, Exception, bool> applyRule

    The custom apply rule function.

    Func<IRawInboundEnvelope, Exception, object> messageToPublishFactory

    The factory that builds the message to be published after the policy is applied.

    IServiceProvider serviceProvider

    The IServiceProvider.

    IInboundLogger<ErrorPolicyBase> logger

    The IInboundLogger<TCategoryName>.

    Methods

    | Improve this doc View source

    ApplyPolicyAsync(ConsumerPipelineContext, Exception)

    Executes the current policy.

    Declaration
    protected abstract Task<bool> ApplyPolicyAsync(ConsumerPipelineContext context, Exception exception)
    Parameters
    Type Name Description
    ConsumerPipelineContext context

    The ConsumerPipelineContext related to the message that failed to be processed.

    Exception exception

    The exception that was thrown during the processing.

    Returns
    Type Description
    Task<bool>

    A Task<TResult> representing the asynchronous operation. The task result contains the action that the consumer should perform (e.g. skip the message or stop consuming).

    | Improve this doc View source

    CanHandle(ConsumerPipelineContext, Exception)

    Returns a boolean value indicating whether the policy can handle the specified envelopes and the specified exception.

    Declaration
    public virtual bool CanHandle(ConsumerPipelineContext context, Exception exception)
    Parameters
    Type Name Description
    ConsumerPipelineContext context

    The ConsumerPipelineContext related to the message that failed to be processed.

    Exception exception

    The exception that was thrown during the processing.

    Returns
    Type Description
    bool

    A value indicating whether the specified envelopes and exception can be handled.

    | Improve this doc View source

    HandleErrorAsync(ConsumerPipelineContext, Exception)

    Performs the necessary actions to handle the error (including invoking the IConsumerTransactionManager).

    Declaration
    public Task<bool> HandleErrorAsync(ConsumerPipelineContext context, Exception exception)
    Parameters
    Type Name Description
    ConsumerPipelineContext context

    The ConsumerPipelineContext related to the message that failed to be processed.

    Exception exception

    The exception that was thrown during the processing.

    Returns
    Type Description
    Task<bool>

    A Task<TResult> representing the asynchronous operation. The task result contains a boolean flag indicating whether the error was handled. If false is returned the exception will be rethrown and the consumer will stop.

    Implements

    IErrorPolicyImplementation
    • Improve this doc
    • View source
    GitHub E-Mail
    ↑ Back to top © 2020 Sergio Aquilini