Class ProducerEndpointConfigurationBuilder<TMessage, TConfiguration, TEndpoint, TBuilder>
- Namespace
- Silverback.Messaging.Configuration
- Assembly
- Silverback.Integration.dll
Builds the ProducerEndpointConfiguration.
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
TMessageThe type of the messages being produced.
TConfigurationThe type of the configuration being built.
TEndpointThe type of the endpoint.
TBuilderThe actual builder type.
- Inheritance
-
EndpointConfigurationBuilder<TMessage, TConfiguration, TBuilder>ProducerEndpointConfigurationBuilder<TMessage, TConfiguration, TEndpoint, TBuilder>
- Implements
-
IMessageSerializationBuilder<TMessage, TBuilder>
- Derived
- Inherited Members
Constructors
ProducerEndpointConfigurationBuilder(IServiceProvider, string?)
Initializes a new instance of the ProducerEndpointConfigurationBuilder<TMessage, TConfiguration, TEndpoint, TBuilder> class.
protected ProducerEndpointConfigurationBuilder(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
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.
public TBuilder AddHeader(string name, Func<IOutboundEnvelope<TMessage>, object?> valueProvider)
Parameters
namestringThe header name.
valueProviderFunc<IOutboundEnvelope<TMessage>, object>The value provider function.
Returns
- 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.
public TBuilder AddHeader(string name, Func<TMessage?, object?> valueProvider)
Parameters
Returns
- TBuilder
The endpoint builder so that additional calls can be chained.
AddHeader(string, object?)
Adds the specified header to all produced messages.
public TBuilder AddHeader(string name, object? value)
Parameters
Returns
- 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.
public TBuilder AddHeader<TMessageChildType>(string name, Func<IOutboundEnvelope<TMessageChildType>, object?> valueProvider) where TMessageChildType : TMessage
Parameters
namestringThe header name.
valueProviderFunc<IOutboundEnvelope<TMessageChildType>, object>The value provider function.
Returns
- TBuilder
The endpoint builder so that additional calls can be chained.
Type Parameters
TMessageChildTypeThe 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.
public TBuilder AddHeader<TMessageChildType>(string name, Func<TMessageChildType?, object?> valueProvider) where TMessageChildType : TMessage
Parameters
namestringThe header name.
valueProviderFunc<TMessageChildType, object>The value provider function.
Returns
- TBuilder
The endpoint builder so that additional calls can be chained.
Type Parameters
TMessageChildTypeThe 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.
public TBuilder AddHeader<TMessageChildType>(string name, object? value) where TMessageChildType : TMessage
Parameters
Returns
- TBuilder
The endpoint builder so that additional calls can be chained.
Type Parameters
TMessageChildTypeThe type of the messages to be enriched with this header.
AddMessageEnricher(IOutboundMessageEnricher)
Adds the specified message enricher.
public TBuilder AddMessageEnricher(IOutboundMessageEnricher enricher)
Parameters
enricherIOutboundMessageEnricherThe IOutboundMessageEnricher to be added.
Returns
- TBuilder
The endpoint builder so that additional calls can be chained.
Build()
Builds the endpoint configuration instance.
public override sealed TConfiguration Build()
Returns
- TConfiguration
The endpoint configuration.
DisableSubscribing()
Disable subscribing to the produced messages.
public TBuilder DisableSubscribing()
Returns
- TBuilder
The endpoint builder so that additional calls can be chained.
EnableChunking(int, bool)
Enables chunking, splitting the larger messages into smaller chunks.
public TBuilder EnableChunking(int chunkSize, bool alwaysAddHeaders = true)
Parameters
chunkSizeintThe maximum chunk size in bytes.
alwaysAddHeadersboolA value indicating whether the
x-chunk-indexand related headers have to be added to the produced message in any case, even if its size doesn't exceed the single chunk size. The default istrue.
Returns
- TBuilder
The endpoint builder so that additional calls can be chained.
EnableSubscribing()
Enable subscribing to the produced messages.
public TBuilder EnableSubscribing()
Returns
- TBuilder
The endpoint builder so that additional calls can be chained.
Encrypt(IEncryptionSettings)
Specifies the settings to be used to encrypt the messages.
public TBuilder Encrypt(IEncryptionSettings encryptionSettings)
Parameters
encryptionSettingsIEncryptionSettingsThe encryption settings.
Returns
- 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.
public TBuilder EncryptUsingAes(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
nulla different IV will be generated for each message and prepended to the actual message payload.
Returns
- 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.
public TBuilder EncryptUsingAes(byte[] key, string keyIdentifier, byte[]? initializationVector = null)
Parameters
keybyte[]The secret key for the symmetric algorithm.
keyIdentifierstringThe 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.
initializationVectorbyte[]The optional initialization vector (IV) for the symmetric algorithm. If
nulla different IV will be generated for each message and prepended to the actual message payload.
Returns
- 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.
public TBuilder Filter(Func<IOutboundEnvelope<TMessage>, bool> filter)
Parameters
filterFunc<IOutboundEnvelope<TMessage>, bool>The filter to be added.
Returns
- 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.
public TBuilder Filter(Func<TMessage?, bool> filter)
Parameters
Returns
- 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.
public TBuilder ProduceBinaryMessages(Action<BinaryMessageSerializerBuilder>? serializerBuilderAction = null)
Parameters
serializerBuilderActionAction<BinaryMessageSerializerBuilder>An optional Action<T> that takes the BinaryMessageSerializerBuilder and configures it.
Returns
- 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.
public TBuilder ProduceDirectly()
Returns
- TBuilder
The endpoint builder so that additional calls can be chained.
ProduceRaw()
Sets the serializer to an instance of RawMessageSerializer to produce the RawMessage.
public TBuilder ProduceRaw()
Returns
- 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.
public TBuilder ProduceStrings(Action<StringMessageSerializerBuilder>? serializerBuilderAction = null)
Parameters
serializerBuilderActionAction<StringMessageSerializerBuilder>An optional Action<T> that takes the StringMessageSerializerBuilder and configures it.
Returns
- 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.
public TBuilder SerializeAsJson(Action<JsonMessageSerializerBuilder>? serializerBuilderAction = null)
Parameters
serializerBuilderActionAction<JsonMessageSerializerBuilder>An optional Action<T> that takes the JsonMessageSerializerBuilder and configures it.
Returns
- TBuilder
The endpoint builder so that additional calls can be chained.
SerializeUsing(IMessageSerializer)
Specifies the IMessageSerializer to be used to serialize the messages.
public TBuilder SerializeUsing(IMessageSerializer serializer)
Parameters
serializerIMessageSerializerThe IMessageSerializer.
Returns
- 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.
public TBuilder StoreToOutbox(OutboxSettings settings)
Parameters
settingsOutboxSettingsThe outbox settings.
Returns
- 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.
public TBuilder StoreToOutbox(Func<OutboxSettingsBuilder, IOutboxSettingsImplementationBuilder> settingsBuilderFunc)
Parameters
settingsBuilderFuncFunc<OutboxSettingsBuilder, IOutboxSettingsImplementationBuilder>A Func<TResult> that takes the OutboxSettingsBuilder and configures it.
Returns
- TBuilder
The endpoint builder so that additional calls can be chained.
UseStrategy(IProduceStrategy)
Specifies the strategy to be used to produce the messages.
public TBuilder UseStrategy(IProduceStrategy strategy)
Parameters
strategyIProduceStrategyThe IProduceStrategy.
Returns
- TBuilder
The endpoint builder so that additional calls can be chained.