Class ProducerEndpointBuilder<TEndpoint, TBuilder>
The base class for the builders of the types inheriting from ConsumerEndpoint.
Inherited Members
Namespace: Silverback.Messaging.Configuration
Assembly: Silverback.Integration.dll
Syntax
public abstract class ProducerEndpointBuilder<TEndpoint, TBuilder> : EndpointBuilder<TEndpoint, TBuilder>, IProducerEndpointBuilder<TBuilder>, IEndpointBuilder<TBuilder> where TEndpoint : ProducerEndpoint where TBuilder : IProducerEndpointBuilder<TBuilder>
Type Parameters
| Name | Description |
|---|---|
| TEndpoint | The type of the endpoint being built. |
| TBuilder | The actual builder type. |
Constructors
| Improve this doc View sourceProducerEndpointBuilder(Type?, IEndpointsConfigurationBuilder?)
Initializes a new instance of the ProducerEndpointBuilder<TEndpoint, TBuilder> class.
Declaration
protected ProducerEndpointBuilder(Type? messageType, IEndpointsConfigurationBuilder? endpointsConfigurationBuilder = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Type | messageType | The type of the message being produced. |
| IEndpointsConfigurationBuilder | endpointsConfigurationBuilder | The optional reference to the IEndpointsConfigurationBuilder that instantiated the builder. |
Methods
| Improve this doc View sourceAddHeader(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<TMessage>(string, Func<IOutboundEnvelope<TMessage>, object?>)
Adds the specified header to all produced messages of the specified type, using a value provider function to determine the header value for each message.
Declaration
public TBuilder AddHeader<TMessage>(string name, Func<IOutboundEnvelope<TMessage>, object?> valueProvider) where TMessage : class
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. |
Type Parameters
| Name | Description |
|---|---|
| TMessage | The type of the messages to be enriched with this header. |
AddHeader<TMessage>(string, object?)
Adds the specified header to all produced messages of the specified type.
Declaration
public TBuilder AddHeader<TMessage>(string name, object? value) where TMessage : class
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 |
|---|---|
| TMessage | The type of the messages to be enriched with this header. |
Build()
Builds the endpoint instance.
Declaration
public override TEndpoint Build()
Returns
| Type | Description |
|---|---|
| TEndpoint | The endpoint. |
Overrides
| Improve this doc View sourceEnableChunking(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. |
Encrypt(EncryptionSettings)
Specifies the EncryptionSettings to be used to encrypt the messages.
Declaration
public TBuilder Encrypt(EncryptionSettings encryptionSettings)
Parameters
| Type | Name | Description |
|---|---|---|
| EncryptionSettings | encryptionSettings | The EncryptionSettings. |
Returns
| Type | Description |
|---|---|
| TBuilder | The endpoint builder so that additional calls can be chained. |
ProduceDirectly()
Specifies that the Silverback.Messaging.Outbound.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. |
ProduceToOutbox()
Specifies that theOutboxProduceStrategy 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 ProduceToOutbox()
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. |
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. |
WithMessageId<TMessage>(Func<IOutboundEnvelope<TMessage>, object?>)
Uses the specified value provider function to set the message id header for each produced message.
Declaration
public TBuilder WithMessageId<TMessage>(Func<IOutboundEnvelope<TMessage>, object?> valueProvider) where TMessage : class
Parameters
| Type | Name | Description |
|---|---|---|
| Func<IOutboundEnvelope<TMessage>, object> | valueProvider | The value provider function. |
Returns
| Type | Description |
|---|---|
| TBuilder | The endpoint builder so that additional calls can be chained. |
Type Parameters
| Name | Description |
|---|---|
| TMessage | The type of the messages to be enriched with this header. |