Table of Contents

Class ConsumerEndpointConfigurationBuilder<TMessage, TConfiguration, TBuilder>

Namespace
Silverback.Messaging.Configuration
Assembly
Silverback.Integration.dll
public abstract class ConsumerEndpointConfigurationBuilder<TMessage, TConfiguration, TBuilder> : EndpointConfigurationBuilder<TMessage, TConfiguration, TBuilder> where TConfiguration : ConsumerEndpointConfiguration where TBuilder : ConsumerEndpointConfigurationBuilder<TMessage, TConfiguration, TBuilder>

Type Parameters

TMessage

The type of the messages being consumed.

TConfiguration

The type of the configuration being built.

TBuilder

The actual builder type.

Inheritance
EndpointConfigurationBuilder<TMessage, TConfiguration, TBuilder>
ConsumerEndpointConfigurationBuilder<TMessage, TConfiguration, TBuilder>
Derived
Inherited Members

Constructors

ConsumerEndpointConfigurationBuilder(IServiceProvider, string?)

protected ConsumerEndpointConfigurationBuilder(IServiceProvider serviceProvider, string? friendlyName)

Parameters

serviceProvider IServiceProvider

The IServiceProvider.

friendlyName string

An optional friendly to be shown in the human-targeted output (e.g. logs, health checks result, etc.).

Methods

Build()

Builds the endpoint configuration instance.

public override sealed TConfiguration Build()

Returns

TConfiguration

The endpoint configuration.

ConsumeBinaryMessages(Action<BinaryMessageDeserializerBuilder>?)

Sets the deserializer to an instance of BinaryMessageDeserializer<TModel> to wrap the consumed binary messages into a BinaryMessage.

public TBuilder ConsumeBinaryMessages(Action<BinaryMessageDeserializerBuilder>? deserializerBuilderAction = null)

Parameters

deserializerBuilderAction Action<BinaryMessageDeserializerBuilder>

An optional Action<T> that takes the BinaryMessageDeserializerBuilder and configures it.

Returns

TBuilder

The endpoint builder so that additional calls can be chained.

ConsumeRaw(Action<RawMessageDeserializerBuilder>?)

Sets the deserializer to an instance of RawMessageDeserializer<T> to return the consumed messages as raws.

public TBuilder ConsumeRaw(Action<RawMessageDeserializerBuilder>? deserializerBuilderAction = null)

Parameters

deserializerBuilderAction Action<RawMessageDeserializerBuilder>

An optional Action<T> that takes the RawMessageDeserializerBuilder and configures it.

Returns

TBuilder

The endpoint builder so that additional calls can be chained.

ConsumeStrings(Action<StringMessageDeserializerBuilder>?)

Sets the deserializer to an instance of StringMessageDeserializer<T> to return the consumed messages as strings.

public TBuilder ConsumeStrings(Action<StringMessageDeserializerBuilder>? deserializerBuilderAction = null)

Parameters

deserializerBuilderAction Action<StringMessageDeserializerBuilder>

An optional Action<T> that takes the StringMessageDeserializerBuilder and configures it.

Returns

TBuilder

The endpoint builder so that additional calls can be chained.

Decrypt(IDecryptionSettings)

Specifies the settings to be used to decrypt the messages.

public TBuilder Decrypt(IDecryptionSettings encryptionSettings)

Parameters

encryptionSettings IDecryptionSettings

The IDecryptionSettings.

Returns

TBuilder

The endpoint builder so that additional calls can be chained.

DecryptUsingAes(byte[], byte[]?)

Specifies that the AES algorithm has to be used to decrypt the messages.

public TBuilder DecryptUsingAes(byte[] key, byte[]? initializationVector = null)

Parameters

key byte[]

The secret key for the symmetric algorithm.

initializationVector byte[]

The optional initialization vector (IV) for the symmetric algorithm. If null it is expected that the IV is prepended to the actual encrypted message.

Returns

TBuilder

The endpoint builder so that additional calls can be chained.

DecryptUsingAes(Func<string?, byte[]>, byte[]?)

Specifies that the AES algorithm has to be used to decrypt the messages.

public TBuilder DecryptUsingAes(Func<string?, byte[]> decryptionKeyProvider, byte[]? initializationVector = null)

Parameters

decryptionKeyProvider Func<string, byte[]>

The function to be used to retrieve the encryption key according to the identifier passed in the header (see EncryptionKeyId).

initializationVector byte[]

The optional initialization vector (IV) for the symmetric algorithm. If null it is expected that the IV is prepended to the actual encrypted message.

Returns

TBuilder

The endpoint builder so that additional calls can be chained.

DeserializeJson(Action<JsonMessageDeserializerBuilder>?)

Sets the deserializer to an instance of JsonMessageDeserializer<TMessage> to deserialize the consumed JSON.

public TBuilder DeserializeJson(Action<JsonMessageDeserializerBuilder>? deserializerBuilderAction = null)

Parameters

deserializerBuilderAction Action<JsonMessageDeserializerBuilder>

An optional Action<T> that takes the JsonMessageDeserializerBuilder and configures it.

Returns

TBuilder

The endpoint builder so that additional calls can be chained.

DeserializeUsing(IMessageDeserializer)

Specifies the IMessageDeserializer to be used to deserialize the messages.

public TBuilder DeserializeUsing(IMessageDeserializer deserializer)

Parameters

deserializer IMessageDeserializer

The IMessageDeserializer.

Returns

TBuilder

The endpoint builder so that additional calls can be chained.

EnableBatchProcessing(int, TimeSpan?)

Enables batch processing.

public TBuilder EnableBatchProcessing(int batchSize, TimeSpan? maxWaitTime = null)

Parameters

batchSize int

The number of messages to be processed in batch.

maxWaitTime TimeSpan?

The maximum amount of time to wait for the batch to be filled. After this time the batch will be completed even if the specified batchSize is not reached.

Returns

TBuilder

The endpoint builder so that additional calls can be chained.

IgnoreUnhandledMessages()

Specifies that the message has to be silently ignored if no subscriber is handling it.

public TBuilder IgnoreUnhandledMessages()

Returns

TBuilder

The endpoint builder so that additional calls can be chained.

OnError(IErrorPolicy)

Specifies the error policy to be applied when an exception occurs during the processing of the consumed messages.

public TBuilder OnError(IErrorPolicy errorPolicy)

Parameters

errorPolicy IErrorPolicy

The IErrorPolicy.

Returns

TBuilder

The endpoint builder so that additional calls can be chained.

OnError(Action<IErrorPolicyBuilder>)

Specifies the error policy to be applied when an exception occurs during the processing of the consumed messages.

public TBuilder OnError(Action<IErrorPolicyBuilder> errorPolicyBuilderAction)

Parameters

errorPolicyBuilderAction Action<IErrorPolicyBuilder>

An Action<T> that takes the Silverback.Messaging.Configuration.ErrorPolicyBuilder and configures it.

Returns

TBuilder

The endpoint builder so that additional calls can be chained.

ThrowIfUnhandled()

Specifies that an exception must be thrown if no subscriber is handling the received message. This option is enabled by default. Use the IgnoreUnhandledMessages() method to disable it.

public TBuilder ThrowIfUnhandled()

Returns

TBuilder

The endpoint builder so that additional calls can be chained.

WithSequenceTimeout(TimeSpan)

Sets the timeout after which an incomplete sequence that isn't pushed with new messages will be aborted and discarded. The default is a conservative 30 minutes.

public TBuilder WithSequenceTimeout(TimeSpan timeout)

Parameters

timeout TimeSpan

The timeout.

Returns

TBuilder

The endpoint builder so that additional calls can be chained.

Remarks

This setting is ignored for batches (BatchSequence), use the maxWaitTime parameter of the EnableBatchProcessing(int, TimeSpan?) method instead.