Class ProducerEndpointConfigurationBuilder<TMessage, TConfiguration, TEndpoint, TBuilder>
Builds the ProducerEndpointConfiguration.
Inheritance
Implements
Inherited Members
Namespace: Silverback.Messaging.Configuration
Assembly: Silverback.Integration.dll
Syntax
public abstract class ProducerEndpointConfigurationBuilder<TMessage, TConfiguration, TEndpoint, TBuilder> : EndpointConfigurationBuilder<TMessage, TConfiguration, TBuilder>, IMessageSerializationBuilder<TMessage, TBuilder> where TConfiguration : ProducerEndpointConfiguration<TEndpoint> where TEndpoint : ProducerEndpoint where TBuilder : ProducerEndpointConfigurationBuilder<TMessage, TConfiguration, TEndpoint, TBuilder>
Type Parameters
| Name | Description |
|---|---|
| TMessage | The type of the messages being produced. |
| TConfiguration | The type of the configuration being built. |
| TEndpoint | The type of the endpoint. |
| TBuilder | The actual builder type. |
Constructors
ProducerEndpointConfigurationBuilder(IServiceProvider, string?)
Initializes a new instance of the ProducerEndpointConfigurationBuilder<TMessage, TConfiguration, TEndpoint, TBuilder> class.
Declaration
protected ProducerEndpointConfigurationBuilder(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
AddHeader(string, Func<IOutboundEnvelope<TMessage>, object?>)
Adds the specified header to all produced messages, using a value provider function to determine the header value for each message.
Declaration
public TBuilder AddHeader(string name, Func<IOutboundEnvelope<TMessage>, object?> valueProvider)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The header name. |
| Func<IOutboundEnvelope<TMessage>, object> | valueProvider | The value provider function. |
Returns
| Type | Description |
|---|---|
| TBuilder | The endpoint builder so that additional calls can be chained. |
AddHeader(string, Func<TMessage?, object?>)
Adds the specified header to all produced messages, using a value provider function to determine the header value for each message.
Declaration
public TBuilder AddHeader(string name, Func<TMessage?, object?> valueProvider)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The header name. |
| Func<TMessage, object> | valueProvider | The value provider function. |
Returns
| Type | Description |
|---|---|
| TBuilder | The endpoint builder so that additional calls can be chained. |
AddHeader(string, object?)
Adds the specified header to all produced messages.
Declaration
public TBuilder AddHeader(string name, object? value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The header name. |
| object | value | The header value. |
Returns
| Type | Description |
|---|---|
| TBuilder | The endpoint builder so that additional calls can be chained. |
AddHeader<TMessageChildType>(string, Func<IOutboundEnvelope<TMessageChildType>, object?>)
Adds the specified header to all produced messages of the specified child type, using a value provider function to determine the header value for each message.
Declaration
public TBuilder AddHeader<TMessageChildType>(string name, Func<IOutboundEnvelope<TMessageChildType>, object?> valueProvider) where TMessageChildType : TMessage
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The header name. |
| Func<IOutboundEnvelope<TMessageChildType>, object> | valueProvider | The value provider function. |
Returns
| Type | Description |
|---|---|
| TBuilder | The endpoint builder so that additional calls can be chained. |
Type Parameters
| Name | Description |
|---|---|
| TMessageChildType | The type of the messages to be enriched with this header. |
AddHeader<TMessageChildType>(string, Func<TMessageChildType?, object?>)
Adds the specified header to all produced messages of the specified child type, using a value provider function to determine the header value for each message.
Declaration
public TBuilder AddHeader<TMessageChildType>(string name, Func<TMessageChildType?, object?> valueProvider) where TMessageChildType : TMessage
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The header name. |
| Func<TMessageChildType, object> | valueProvider | The value provider function. |
Returns
| Type | Description |
|---|---|
| TBuilder | The endpoint builder so that additional calls can be chained. |
Type Parameters
| Name | Description |
|---|---|
| TMessageChildType | The type of the messages to be enriched with this header. |
AddHeader<TMessageChildType>(string, object?)
Adds the specified header to all produced messages of the specified child type.
Declaration
public TBuilder AddHeader<TMessageChildType>(string name, object? value) where TMessageChildType : TMessage
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The header name. |
| object | value | The header value. |
Returns
| Type | Description |
|---|---|
| TBuilder | The endpoint builder so that additional calls can be chained. |
Type Parameters
| Name | Description |
|---|---|
| TMessageChildType | The type of the messages to be enriched with this header. |
AddMessageEnricher(IOutboundMessageEnricher)
Adds the specified message enricher.
Declaration
public TBuilder AddMessageEnricher(IOutboundMessageEnricher enricher)
Parameters
| Type | Name | Description |
|---|---|---|
| IOutboundMessageEnricher | enricher | The IOutboundMessageEnricher to be added. |
Returns
| Type | Description |
|---|---|
| TBuilder | The endpoint builder so that additional calls can be chained. |
Build()
Builds the endpoint configuration instance.
Declaration
public override sealed TConfiguration Build()
Returns
| Type | Description |
|---|---|
| TConfiguration | The endpoint configuration. |
Overrides
DisableSubscribing()
Disable subscribing to the produced messages.
Declaration
public TBuilder DisableSubscribing()
Returns
| Type | Description |
|---|---|
| TBuilder | The endpoint builder so that additional calls can be chained. |
EnableChunking(int, bool)
Enables chunking, splitting the larger messages into smaller chunks.
Declaration
public TBuilder EnableChunking(int chunkSize, bool alwaysAddHeaders = true)
Parameters
| Type | Name | Description |
|---|---|---|
| int | chunkSize | The maximum chunk size in bytes. |
| bool | alwaysAddHeaders | A value indicating whether the |
Returns
| Type | Description |
|---|---|
| TBuilder | The endpoint builder so that additional calls can be chained. |
EnableSubscribing()
Enable subscribing to the produced messages.
Declaration
public TBuilder EnableSubscribing()
Returns
| Type | Description |
|---|---|
| TBuilder | The endpoint builder so that additional calls can be chained. |
Encrypt(IEncryptionSettings)
Specifies the settings to be used to encrypt the messages.
Declaration
public TBuilder Encrypt(IEncryptionSettings encryptionSettings)
Parameters
| Type | Name | Description |
|---|---|---|
| IEncryptionSettings | encryptionSettings | The encryption settings. |
Returns
| Type | Description |
|---|---|
| TBuilder | The endpoint builder so that additional calls can be chained. |
EncryptUsingAes(byte[], byte[]?)
Specifies that the AES algorithm has to be used to encrypt the messages.
Declaration
public TBuilder EncryptUsingAes(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. |
EncryptUsingAes(byte[], string, byte[]?)
Specifies that the AES algorithm has to be used to encrypt the messages.
Declaration
public TBuilder EncryptUsingAes(byte[] key, string keyIdentifier, byte[]? initializationVector = null)
Parameters
| Type | Name | Description |
|---|---|---|
| byte[] | key | The secret key for the symmetric algorithm. |
| string | keyIdentifier | The key identifier to be sent in the header (see EncryptionKeyId). When rotating keys, it will be used on the consumer side to determine the correct key to be used to decrypt the message. |
| 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. |
Filter(Func<IOutboundEnvelope<TMessage>, bool>)
Adds the specified filter, to filter out the messages that should not be produced.
Declaration
public TBuilder Filter(Func<IOutboundEnvelope<TMessage>, bool> filter)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<IOutboundEnvelope<TMessage>, bool> | filter | The filter to be added. |
Returns
| Type | Description |
|---|---|
| TBuilder | The endpoint builder so that additional calls can be chained. |
Filter(Func<TMessage?, bool>)
Adds the specified filter, to filter out the messages that should not be produced.
Declaration
public TBuilder Filter(Func<TMessage?, bool> filter)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<TMessage, bool> | filter | The filter to be added. |
Returns
| Type | Description |
|---|---|
| TBuilder | The endpoint builder so that additional calls can be chained. |
ProduceBinaryMessages(Action<BinaryMessageSerializerBuilder>?)
Sets the serializer to an instance of BinaryMessageSerializer to produce the IBinaryMessage.
Declaration
public TBuilder ProduceBinaryMessages(Action<BinaryMessageSerializerBuilder>? serializerBuilderAction = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Action<BinaryMessageSerializerBuilder> | serializerBuilderAction | An optional Action<T> that takes the BinaryMessageSerializerBuilder and configures it. |
Returns
| Type | Description |
|---|---|
| TBuilder | The endpoint builder so that additional calls can be chained. |
ProduceDirectly()
Specifies that the DefaultProduceStrategy has to be used, producing directly to the message broker.
Declaration
public TBuilder ProduceDirectly()
Returns
| Type | Description |
|---|---|
| TBuilder | The endpoint builder so that additional calls can be chained. |
ProduceRaw()
Sets the serializer to an instance of RawMessageSerializer to produce the RawMessage.
Declaration
public TBuilder ProduceRaw()
Returns
| Type | Description |
|---|---|
| TBuilder | The endpoint builder so that additional calls can be chained. |
ProduceStrings(Action<StringMessageSerializerBuilder>?)
Sets the serializer to an instance of StringMessageSerializer to produce the StringMessage.
Declaration
public TBuilder ProduceStrings(Action<StringMessageSerializerBuilder>? serializerBuilderAction = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Action<StringMessageSerializerBuilder> | serializerBuilderAction | An optional Action<T> that takes the StringMessageSerializerBuilder and configures it. |
Returns
| Type | Description |
|---|---|
| TBuilder | The endpoint builder so that additional calls can be chained. |
SerializeAsJson(Action<JsonMessageSerializerBuilder>?)
Sets the serializer to an instance of JsonMessageSerializer to serialize the produced messages as JSON.
Declaration
public TBuilder SerializeAsJson(Action<JsonMessageSerializerBuilder>? serializerBuilderAction = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Action<JsonMessageSerializerBuilder> | serializerBuilderAction | An optional Action<T> that takes the JsonMessageSerializerBuilder and configures it. |
Returns
| Type | Description |
|---|---|
| TBuilder | The endpoint builder so that additional calls can be chained. |
SerializeUsing(IMessageSerializer)
Specifies the IMessageSerializer to be used to serialize the messages.
Declaration
public TBuilder SerializeUsing(IMessageSerializer serializer)
Parameters
| Type | Name | Description |
|---|---|---|
| IMessageSerializer | serializer | The IMessageSerializer. |
Returns
| Type | Description |
|---|---|
| TBuilder | The endpoint builder so that additional calls can be chained. |
StoreToOutbox(OutboxSettings)
Specifies that the OutboxProduceStrategy has to be used, storing the messages into the transactional outbox table. The operation is therefore included in the database transaction applying the message side effects to the local database. The IOutboxWorker takes care of asynchronously sending the messages to the message broker.
Declaration
public TBuilder StoreToOutbox(OutboxSettings settings)
Parameters
| Type | Name | Description |
|---|---|---|
| OutboxSettings | settings | The outbox settings. |
Returns
| Type | Description |
|---|---|
| TBuilder | The endpoint builder so that additional calls can be chained. |
StoreToOutbox(Func<OutboxSettingsBuilder, IOutboxSettingsImplementationBuilder>)
Specifies that the OutboxProduceStrategy has to be used, storing the messages into the transactional outbox table. The operation is therefore included in the database transaction applying the message side effects to the local database. The IOutboxWorker takes care of asynchronously sending the messages to the message broker.
Declaration
public TBuilder StoreToOutbox(Func<OutboxSettingsBuilder, IOutboxSettingsImplementationBuilder> settingsBuilderFunc)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<OutboxSettingsBuilder, IOutboxSettingsImplementationBuilder> | settingsBuilderFunc | A Func<TResult> that takes the OutboxSettingsBuilder and configures it. |
Returns
| Type | Description |
|---|---|
| TBuilder | The endpoint builder so that additional calls can be chained. |
UseStrategy(IProduceStrategy)
Specifies the strategy to be used to produce the messages.
Declaration
public TBuilder UseStrategy(IProduceStrategy strategy)
Parameters
| Type | Name | Description |
|---|---|---|
| IProduceStrategy | strategy | The IProduceStrategy. |
Returns
| Type | Description |
|---|---|
| TBuilder | The endpoint builder so that additional calls can be chained. |