Class ConsumerEndpointConfigurationBuilder<TMessage, TConfiguration, TBuilder>
Builds the ConsumerEndpointConfiguration.
Inheritance
Inherited Members
Namespace: Silverback.Messaging.Configuration
Assembly: Silverback.Integration.dll
Syntax
public abstract class ConsumerEndpointConfigurationBuilder<TMessage, TConfiguration, TBuilder> : EndpointConfigurationBuilder<TMessage, TConfiguration, TBuilder> where TConfiguration : ConsumerEndpointConfiguration where TBuilder : ConsumerEndpointConfigurationBuilder<TMessage, TConfiguration, TBuilder>
Type Parameters
| Name | Description |
|---|---|
| TMessage | The type of the messages being consumed. |
| TConfiguration | The type of the configuration being built. |
| TBuilder | The actual builder type. |
Constructors
ConsumerEndpointConfigurationBuilder(IServiceProvider, string?)
Initializes a new instance of the ConsumerEndpointConfigurationBuilder<TMessage, TConfiguration, TBuilder> class.
Declaration
protected ConsumerEndpointConfigurationBuilder(IServiceProvider serviceProvider, string? friendlyName)
Parameters
| Type | Name | Description |
|---|---|---|
| IServiceProvider | serviceProvider | The IServiceProvider. |
| string | friendlyName | 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.
Declaration
public override sealed TConfiguration Build()
Returns
| Type | Description |
|---|---|
| TConfiguration | The endpoint configuration. |
Overrides
ConsumeBinaryMessages(Action<BinaryMessageDeserializerBuilder>?)
Sets the deserializer to an instance of BinaryMessageDeserializer<TModel> to wrap the consumed binary messages into a BinaryMessage.
Declaration
public TBuilder ConsumeBinaryMessages(Action<BinaryMessageDeserializerBuilder>? deserializerBuilderAction = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Action<BinaryMessageDeserializerBuilder> | deserializerBuilderAction | An optional Action<T> that takes the BinaryMessageDeserializerBuilder and configures it. |
Returns
| Type | Description |
|---|---|
| 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.
Declaration
public TBuilder ConsumeRaw(Action<RawMessageDeserializerBuilder>? deserializerBuilderAction = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Action<RawMessageDeserializerBuilder> | deserializerBuilderAction | An optional Action<T> that takes the RawMessageDeserializerBuilder and configures it. |
Returns
| Type | Description |
|---|---|
| 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.
Declaration
public TBuilder ConsumeStrings(Action<StringMessageDeserializerBuilder>? deserializerBuilderAction = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Action<StringMessageDeserializerBuilder> | deserializerBuilderAction | An optional Action<T> that takes the StringMessageDeserializerBuilder and configures it. |
Returns
| Type | Description |
|---|---|
| TBuilder | The endpoint builder so that additional calls can be chained. |
Decrypt(IDecryptionSettings)
Specifies the settings to be used to decrypt the messages.
Declaration
public TBuilder Decrypt(IDecryptionSettings encryptionSettings)
Parameters
| Type | Name | Description |
|---|---|---|
| IDecryptionSettings | encryptionSettings | The IDecryptionSettings. |
Returns
| Type | Description |
|---|---|
| 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.
Declaration
public TBuilder DecryptUsingAes(byte[] key, byte[]? initializationVector = null)
Parameters
| Type | Name | Description |
|---|---|---|
| byte[] | key | The secret key for the symmetric algorithm. |
| byte[] | initializationVector | The optional initialization vector (IV) for the symmetric algorithm. If |
Returns
| Type | Description |
|---|---|
| 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.
Declaration
public TBuilder DecryptUsingAes(Func<string?, byte[]> decryptionKeyProvider, byte[]? initializationVector = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<string, byte[]> | decryptionKeyProvider | The function to be used to retrieve the encryption key according to the identifier passed in the header (see EncryptionKeyId). |
| byte[] | initializationVector | The optional initialization vector (IV) for the symmetric algorithm. If |
Returns
| Type | Description |
|---|---|
| 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.
Declaration
public TBuilder DeserializeJson(Action<JsonMessageDeserializerBuilder>? deserializerBuilderAction = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Action<JsonMessageDeserializerBuilder> | deserializerBuilderAction | An optional Action<T> that takes the JsonMessageDeserializerBuilder and configures it. |
Returns
| Type | Description |
|---|---|
| TBuilder | The endpoint builder so that additional calls can be chained. |
DeserializeUsing(IMessageDeserializer)
Specifies the IMessageDeserializer to be used to deserialize the messages.
Declaration
public TBuilder DeserializeUsing(IMessageDeserializer deserializer)
Parameters
| Type | Name | Description |
|---|---|---|
| IMessageDeserializer | deserializer | The IMessageDeserializer. |
Returns
| Type | Description |
|---|---|
| TBuilder | The endpoint builder so that additional calls can be chained. |
EnableBatchProcessing(int, TimeSpan?)
Enables batch processing.
Declaration
public TBuilder EnableBatchProcessing(int batchSize, TimeSpan? maxWaitTime = null)
Parameters
| Type | Name | Description |
|---|---|---|
| int | batchSize | The number of messages to be processed in batch. |
| TimeSpan? | maxWaitTime | 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 |
Returns
| Type | Description |
|---|---|
| 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.
Declaration
public TBuilder IgnoreUnhandledMessages()
Returns
| Type | Description |
|---|---|
| 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.
Declaration
public TBuilder OnError(IErrorPolicy errorPolicy)
Parameters
| Type | Name | Description |
|---|---|---|
| IErrorPolicy | errorPolicy | The IErrorPolicy. |
Returns
| Type | Description |
|---|---|
| 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.
Declaration
public TBuilder OnError(Action<IErrorPolicyBuilder> errorPolicyBuilderAction)
Parameters
| Type | Name | Description |
|---|---|---|
| Action<IErrorPolicyBuilder> | errorPolicyBuilderAction | An Action<T> that takes the Silverback.Messaging.Configuration.ErrorPolicyBuilder and configures it. |
Returns
| Type | Description |
|---|---|
| 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.
Declaration
public TBuilder ThrowIfUnhandled()
Returns
| Type | Description |
|---|---|
| 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.
Declaration
public TBuilder WithSequenceTimeout(TimeSpan timeout)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan | timeout | The timeout. |
Returns
| Type | Description |
|---|---|
| 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.