Class KafkaProducerEndpointConfigurationBuilder<TMessage>
Builds the KafkaProducerEndpointConfiguration.
Inheritance
Implements
Inherited Members
Namespace: Silverback.Messaging.Configuration.Kafka
Assembly: Silverback.Integration.Kafka.dll
Syntax
public sealed class KafkaProducerEndpointConfigurationBuilder<TMessage> : ProducerEndpointConfigurationBuilder<TMessage, KafkaProducerEndpointConfiguration, KafkaProducerEndpoint, KafkaProducerEndpointConfigurationBuilder<TMessage>>, IMessageSerializationBuilder<TMessage, KafkaProducerEndpointConfigurationBuilder<TMessage>> where TMessage : class
Type Parameters
| Name | Description |
|---|---|
| TMessage | The type of the messages being produced. |
Constructors
KafkaProducerEndpointConfigurationBuilder(IServiceProvider, string?)
Initializes a new instance of the KafkaProducerEndpointConfigurationBuilder<TMessage> class.
Declaration
public KafkaProducerEndpointConfigurationBuilder(IServiceProvider serviceProvider, string? friendlyName = null)
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.). |
Properties
This
Gets this instance.
Declaration
protected override KafkaProducerEndpointConfigurationBuilder<TMessage> This { get; }
Property Value
| Type | Description |
|---|---|
| KafkaProducerEndpointConfigurationBuilder<TMessage> |
Overrides
Remarks
This is necessary to work around casting in the base classes.
Methods
CreateConfiguration()
Creates the TConfiguration instance.
Declaration
protected override KafkaProducerEndpointConfiguration CreateConfiguration()
Returns
| Type | Description |
|---|---|
| KafkaProducerEndpointConfiguration | The endpoint. |
Overrides
ProduceTo(TopicPartition)
Specifies the target topic and partition.
Declaration
public KafkaProducerEndpointConfigurationBuilder<TMessage> ProduceTo(TopicPartition topicPartition)
Parameters
| Type | Name | Description |
|---|---|---|
| TopicPartition | topicPartition | The target topic and partition. |
Returns
| Type | Description |
|---|---|
| KafkaProducerEndpointConfigurationBuilder<TMessage> | The KafkaProducerEndpointConfigurationBuilder<TMessage> so that additional calls can be chained. |
ProduceTo(Func<IOutboundEnvelope<TMessage>, TopicPartition>)
Specifies the function returning the target topic and partition for each message being produced.
Declaration
public KafkaProducerEndpointConfigurationBuilder<TMessage> ProduceTo(Func<IOutboundEnvelope<TMessage>, TopicPartition> topicPartitionFunction)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<IOutboundEnvelope<TMessage>, TopicPartition> | topicPartitionFunction | The function returning the target topic and partition index for the message being produced. |
Returns
| Type | Description |
|---|---|
| KafkaProducerEndpointConfigurationBuilder<TMessage> | The KafkaProducerEndpointConfigurationBuilder<TMessage> so that additional calls can be chained. |
ProduceTo(Func<IOutboundEnvelope<TMessage>, string>, Func<IOutboundEnvelope<TMessage>, int>?)
Specifies the functions returning the target topic and partition for each message being produced.
Declaration
public KafkaProducerEndpointConfigurationBuilder<TMessage> ProduceTo(Func<IOutboundEnvelope<TMessage>, string> topicFunction, Func<IOutboundEnvelope<TMessage>, int>? partitionFunction = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<IOutboundEnvelope<TMessage>, string> | topicFunction | The function returning the target topic for the message being produced. |
| Func<IOutboundEnvelope<TMessage>, int> | partitionFunction | The optional function returning the target partition index for the message being produced. If |
Returns
| Type | Description |
|---|---|
| KafkaProducerEndpointConfigurationBuilder<TMessage> | The KafkaProducerEndpointConfigurationBuilder<TMessage> so that additional calls can be chained. |
ProduceTo(Func<TMessage?, TopicPartition>)
Specifies the function returning the target topic and partition for each message being produced.
Declaration
public KafkaProducerEndpointConfigurationBuilder<TMessage> ProduceTo(Func<TMessage?, TopicPartition> topicPartitionFunction)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<TMessage, TopicPartition> | topicPartitionFunction | The function returning the target topic and partition index for the message being produced. |
Returns
| Type | Description |
|---|---|
| KafkaProducerEndpointConfigurationBuilder<TMessage> | The KafkaProducerEndpointConfigurationBuilder<TMessage> so that additional calls can be chained. |
ProduceTo(Func<TMessage?, string>, Func<TMessage?, int>?)
Specifies the functions returning the target topic and partition for each message being produced.
Declaration
public KafkaProducerEndpointConfigurationBuilder<TMessage> ProduceTo(Func<TMessage?, string> topicFunction, Func<TMessage?, int>? partitionFunction = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<TMessage, string> | topicFunction | The function returning the target topic for the message being produced. |
| Func<TMessage, int> | partitionFunction | The optional function returning the target partition index for the message being produced. If |
Returns
| Type | Description |
|---|---|
| KafkaProducerEndpointConfigurationBuilder<TMessage> | The KafkaProducerEndpointConfigurationBuilder<TMessage> so that additional calls can be chained. |
ProduceTo(string, Func<IOutboundEnvelope<TMessage>, int>)
Specifies the target topic and the function returning the target partition for each message being produced.
Declaration
public KafkaProducerEndpointConfigurationBuilder<TMessage> ProduceTo(string topic, Func<IOutboundEnvelope<TMessage>, int> partitionFunction)
Parameters
| Type | Name | Description |
|---|---|---|
| string | topic | The target topic. |
| Func<IOutboundEnvelope<TMessage>, int> | partitionFunction | The function returning the target partition index for the message being produced. |
Returns
| Type | Description |
|---|---|
| KafkaProducerEndpointConfigurationBuilder<TMessage> | The KafkaProducerEndpointConfigurationBuilder<TMessage> so that additional calls can be chained. |
ProduceTo(string, Func<IOutboundEnvelope<TMessage>, string[]>, Func<IOutboundEnvelope<TMessage>, int>?)
Specifies the target topic format and an optional function returning the target partition for each message being produced.
Declaration
public KafkaProducerEndpointConfigurationBuilder<TMessage> ProduceTo(string topicFormatString, Func<IOutboundEnvelope<TMessage>, string[]> topicArgumentsFunction, Func<IOutboundEnvelope<TMessage>, int>? partitionFunction = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | topicFormatString | The topic format string that will be combined with the arguments returned by the |
| Func<IOutboundEnvelope<TMessage>, string[]> | topicArgumentsFunction | The function returning the arguments to be used to format the string. |
| Func<IOutboundEnvelope<TMessage>, int> | partitionFunction | The optional function returning the target partition index for the message being produced. If |
Returns
| Type | Description |
|---|---|
| KafkaProducerEndpointConfigurationBuilder<TMessage> | The KafkaProducerEndpointConfigurationBuilder<TMessage> so that additional calls can be chained. |
ProduceTo(string, Func<TMessage?, int>)
Specifies the target topic and the function returning the target partition for each message being produced.
Declaration
public KafkaProducerEndpointConfigurationBuilder<TMessage> ProduceTo(string topic, Func<TMessage?, int> partitionFunction)
Parameters
| Type | Name | Description |
|---|---|---|
| string | topic | The target topic. |
| Func<TMessage, int> | partitionFunction | The function returning the target partition index for the message being produced. |
Returns
| Type | Description |
|---|---|
| KafkaProducerEndpointConfigurationBuilder<TMessage> | The KafkaProducerEndpointConfigurationBuilder<TMessage> so that additional calls can be chained. |
ProduceTo(string, Func<TMessage?, string[]>, Func<TMessage?, int>?)
Specifies the target topic format and an optional function returning the target partition for each message being produced.
Declaration
public KafkaProducerEndpointConfigurationBuilder<TMessage> ProduceTo(string topicFormatString, Func<TMessage?, string[]> topicArgumentsFunction, Func<TMessage?, int>? partitionFunction = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | topicFormatString | The topic format string that will be combined with the arguments returned by the |
| Func<TMessage, string[]> | topicArgumentsFunction | The function returning the arguments to be used to format the string. |
| Func<TMessage, int> | partitionFunction | The optional function returning the target partition index for the message being produced. If |
Returns
| Type | Description |
|---|---|
| KafkaProducerEndpointConfigurationBuilder<TMessage> | The KafkaProducerEndpointConfigurationBuilder<TMessage> so that additional calls can be chained. |
ProduceTo(string, int?)
Specifies the target topic and optionally the target partition.
Declaration
public KafkaProducerEndpointConfigurationBuilder<TMessage> ProduceTo(string topic, int? partition = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | topic | The target topic. |
| int? | partition | The optional target partition index. If |
Returns
| Type | Description |
|---|---|
| KafkaProducerEndpointConfigurationBuilder<TMessage> | The KafkaProducerEndpointConfigurationBuilder<TMessage> so that additional calls can be chained. |
ProduceToDynamicTopic()
Specifies that the target topic and, optionally, the target partition will be specified per each message using the envelope's SetKafkaDestinationTopic(IOutboundEnvelope, string, int?) extension method.
Declaration
public KafkaProducerEndpointConfigurationBuilder<TMessage> ProduceToDynamicTopic()
Returns
| Type | Description |
|---|---|
| KafkaProducerEndpointConfigurationBuilder<TMessage> | The KafkaProducerEndpointConfigurationBuilder<TMessage> so that additional calls can be chained. |
SetKafkaKey(Func<IOutboundEnvelope<TMessage>, object?>)
Uses the specified value provider function to set the kafka key for each message being produced.
Declaration
public KafkaProducerEndpointConfigurationBuilder<TMessage> SetKafkaKey(Func<IOutboundEnvelope<TMessage>, object?> valueProvider)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<IOutboundEnvelope<TMessage>, object> | valueProvider | The value provider function. |
Returns
| Type | Description |
|---|---|
| KafkaProducerEndpointConfigurationBuilder<TMessage> | The KafkaProducerEndpointConfigurationBuilder<TMessage> so that additional calls can be chained. |
SetKafkaKey(Func<TMessage?, object?>)
Uses the specified value provider function to set the kafka key for each message being produced.
Declaration
public KafkaProducerEndpointConfigurationBuilder<TMessage> SetKafkaKey(Func<TMessage?, object?> valueProvider)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<TMessage, object> | valueProvider | The value provider function. |
Returns
| Type | Description |
|---|---|
| KafkaProducerEndpointConfigurationBuilder<TMessage> | The KafkaProducerEndpointConfigurationBuilder<TMessage> so that additional calls can be chained. |
SetKafkaKey<TMessageChildType>(Func<IOutboundEnvelope<TMessageChildType>, object?>)
Uses the specified value provider function to set the kafka key for each message being produced.
Declaration
public KafkaProducerEndpointConfigurationBuilder<TMessage> SetKafkaKey<TMessageChildType>(Func<IOutboundEnvelope<TMessageChildType>, object?> valueProvider) where TMessageChildType : TMessage
Parameters
| Type | Name | Description |
|---|---|---|
| Func<IOutboundEnvelope<TMessageChildType>, object> | valueProvider | The value provider function. |
Returns
| Type | Description |
|---|---|
| KafkaProducerEndpointConfigurationBuilder<TMessage> | The KafkaProducerEndpointConfigurationBuilder<TMessage> so that additional calls can be chained. |
Type Parameters
| Name | Description |
|---|---|
| TMessageChildType | The type of the messages to be enriched with this kafka key. |
SetKafkaKey<TMessageChildType>(Func<TMessageChildType?, object?>)
Uses the specified value provider function to set the kafka key for each message being produced.
Declaration
public KafkaProducerEndpointConfigurationBuilder<TMessage> SetKafkaKey<TMessageChildType>(Func<TMessageChildType?, object?> valueProvider) where TMessageChildType : TMessage
Parameters
| Type | Name | Description |
|---|---|---|
| Func<TMessageChildType, object> | valueProvider | The value provider function. |
Returns
| Type | Description |
|---|---|
| KafkaProducerEndpointConfigurationBuilder<TMessage> | The KafkaProducerEndpointConfigurationBuilder<TMessage> so that additional calls can be chained. |
Type Parameters
| Name | Description |
|---|---|
| TMessageChildType | The type of the messages to be enriched with this kafka key. |
UseEndpointResolver<TResolver>()
Specifies the type of the IKafkaProducerEndpointResolver<TMessage> to be used to resolve the target topic and partition for each message being produced.
Declaration
public KafkaProducerEndpointConfigurationBuilder<TMessage> UseEndpointResolver<TResolver>() where TResolver : IKafkaProducerEndpointResolver<TMessage>
Returns
| Type | Description |
|---|---|
| KafkaProducerEndpointConfigurationBuilder<TMessage> | The KafkaProducerEndpointConfigurationBuilder<TMessage> so that additional calls can be chained. |
Type Parameters
| Name | Description |
|---|---|
| TResolver | The type of the IKafkaProducerEndpointResolver<TMessage> to be used. |