Table of Contents

Class GenericOutboundMessageFilter<TMessage>

Namespace
Silverback.Messaging.Producing.Filter
Assembly
Silverback.Integration.dll

Can be used to filter the messages to be produced based on the message content.

public class GenericOutboundMessageFilter<TMessage> : IOutboundMessageFilter

Type Parameters

TMessage

The type of the messages to be filtered.

Inheritance
GenericOutboundMessageFilter<TMessage>
Implements
Inherited Members

Constructors

GenericOutboundMessageFilter(Func<IOutboundEnvelope<TMessage>, bool>)

Initializes a new instance of the GenericOutboundMessageFilter<TMessage> class.

public GenericOutboundMessageFilter(Func<IOutboundEnvelope<TMessage>, bool> filter)

Parameters

filter Func<IOutboundEnvelope<TMessage>, bool>

The filter function. If it returns true the message will be produced, otherwise it will be skipped.

GenericOutboundMessageFilter(Func<TMessage?, bool>)

Initializes a new instance of the GenericOutboundMessageFilter<TMessage> class.

public GenericOutboundMessageFilter(Func<TMessage?, bool> filter)

Parameters

filter Func<TMessage, bool>

The filter function. If it returns true the message will be produced, otherwise it will be skipped.

Methods

ShouldProduceAsync(IOutboundEnvelope, CancellationToken)

Returns a value indicating whether the specified message should be produced.

public ValueTask<bool> ShouldProduceAsync(IOutboundEnvelope envelope, CancellationToken cancellationToken)

Parameters

envelope IOutboundEnvelope

The envelope containing the message to be filtered.

cancellationToken CancellationToken

A CancellationToken used to cancel the operation.

Returns

ValueTask<bool>

A ValueTask<TResult> representing the asynchronous operation. The task result contains a value indicating whether the message should be produced.

Remarks

The filter might also be invoked while the caller synchronously waits for the message to be produced, for example when using the synchronous IProducer or IPublisher methods or when publishing a batch. Use ConfigureAwait(false) when awaiting and keep the asynchronous work short, to avoid deadlocks and blocked threads.