Class ConsumerEndpointConfigurationBuilder<TMessage, TConfiguration, TBuilder>
- Namespace
- Silverback.Messaging.Configuration
- Assembly
- Silverback.Integration.dll
Builds the ConsumerEndpointConfiguration.
public abstract class ConsumerEndpointConfigurationBuilder<TMessage, TConfiguration, TBuilder> : EndpointConfigurationBuilder<TMessage, TConfiguration, TBuilder> where TConfiguration : ConsumerEndpointConfiguration where TBuilder : ConsumerEndpointConfigurationBuilder<TMessage, TConfiguration, TBuilder>
Type Parameters
TMessageThe type of the messages being consumed.
TConfigurationThe type of the configuration being built.
TBuilderThe actual builder type.
- Inheritance
-
EndpointConfigurationBuilder<TMessage, TConfiguration, TBuilder>ConsumerEndpointConfigurationBuilder<TMessage, TConfiguration, TBuilder>
- Derived
- Inherited Members
Constructors
ConsumerEndpointConfigurationBuilder(IServiceProvider, string?)
Initializes a new instance of the ConsumerEndpointConfigurationBuilder<TMessage, TConfiguration, TBuilder> class.
protected ConsumerEndpointConfigurationBuilder(IServiceProvider serviceProvider, string? friendlyName)
Parameters
serviceProviderIServiceProviderThe IServiceProvider.
friendlyNamestringAn 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
deserializerBuilderActionAction<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
deserializerBuilderActionAction<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
deserializerBuilderActionAction<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
encryptionSettingsIDecryptionSettingsThe 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
keybyte[]The secret key for the symmetric algorithm.
initializationVectorbyte[]The optional initialization vector (IV) for the symmetric algorithm. If
nullit 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
decryptionKeyProviderFunc<string, byte[]>The function to be used to retrieve the encryption key according to the identifier passed in the header (see EncryptionKeyId).
initializationVectorbyte[]The optional initialization vector (IV) for the symmetric algorithm. If
nullit 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
deserializerBuilderActionAction<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
deserializerIMessageDeserializerThe 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
batchSizeintThe number of messages to be processed in batch.
maxWaitTimeTimeSpan?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
batchSizeis 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
errorPolicyIErrorPolicyThe 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
errorPolicyBuilderActionAction<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
timeoutTimeSpanThe 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.