Audit Filter

Source
NuGet Package NServiceBus.AuditFilter (1.x) | License
This is a community maintained project. License and support are independent of Particular Software.
Target NServiceBus Version: 7.x

NServiceBus.AuditFilter adds support for filtering which messages are sent to the Audit Queue.

Usage

Decorate messages with attributes

[IncludeInAudit]
public class MessageToIncludeAudit :
    IMessage
{
}
[ExcludeFromAudit]
public class MessageToExcludeFromAudit :
    IMessage
{
}

Add to EndpointConfiguration

With include by default

endpointConfiguration.FilterAuditQueue(FilterResult.IncludeInAudit);

With exclude by default

endpointConfiguration.FilterAuditQueue(FilterResult.ExcludeFromAudit);

Delegate filter fallback

The fallback/default value can also be controlled by a delegate.

endpointConfiguration.FilterAuditQueue(
    filter: (instance, headers) =>
    {
        if (instance is MyMessage)
        {
            return FilterResult.ExcludeFromAudit;
        }

        return FilterResult.IncludeInAudit;
    });

Include/Exclude logic flow

graph TD HasExcludeAttribute{Has Exclude<br />Attribute?} HasIncludeAttribute{Has Include<br />Attribute?} Include[Include in Audit] Exclude[Exclude From Audit] Default{What is the<br /> default?} HasFilter{Has Filter<br />Defined?} WhatFilter{Filter return<br /> value?} HasIncludeAttribute --Yes--> Include HasIncludeAttribute --No--> HasExcludeAttribute HasExcludeAttribute --No--> HasFilter HasExcludeAttribute --Yes--> Exclude HasFilter--Yes--> WhatFilter WhatFilter--Include--> Include WhatFilter--Exclude--> Exclude HasFilter--No--> Default Default--Include--> Include Default--Exclude--> Exclude

Samples


Last modified