Class KafkaProducerEndpointConfigurationBuilder<TMessage>
- Namespace
- Silverback.Messaging.Configuration.Kafka
- Assembly
- Silverback.Integration.Kafka.dll
Builds the KafkaProducerEndpointConfiguration.
public sealed class KafkaProducerEndpointConfigurationBuilder<TMessage> : ProducerEndpointConfigurationBuilder<TMessage, KafkaProducerEndpointConfiguration, KafkaProducerEndpoint, KafkaProducerEndpointConfigurationBuilder<TMessage>>, IMessageSerializationBuilder<TMessage, KafkaProducerEndpointConfigurationBuilder<TMessage>> where TMessage : class
Type Parameters
TMessageThe type of the messages being produced.
- Inheritance
-
EndpointConfigurationBuilder<TMessage, KafkaProducerEndpointConfiguration, KafkaProducerEndpointConfigurationBuilder<TMessage>>ProducerEndpointConfigurationBuilder<TMessage, KafkaProducerEndpointConfiguration, KafkaProducerEndpoint, KafkaProducerEndpointConfigurationBuilder<TMessage>>KafkaProducerEndpointConfigurationBuilder<TMessage>
- Implements
-
IMessageSerializationBuilder<TMessage, KafkaProducerEndpointConfigurationBuilder<TMessage>>
- Inherited Members
Constructors
KafkaProducerEndpointConfigurationBuilder(IServiceProvider, string?)
Initializes a new instance of the KafkaProducerEndpointConfigurationBuilder<TMessage> class.
public KafkaProducerEndpointConfigurationBuilder(IServiceProvider serviceProvider, string? friendlyName = null)
Parameters
serviceProviderIServiceProviderThe IServiceProvider.
friendlyNamestringAn optional friendly to be shown in the human-targeted output (e.g. logs, health checks result, etc.).
Properties
This
Gets this instance.
protected override KafkaProducerEndpointConfigurationBuilder<TMessage> This { get; }
Property Value
Remarks
This is necessary to work around casting in the base classes.
Methods
CreateConfiguration()
Creates the TConfiguration instance.
protected override KafkaProducerEndpointConfiguration CreateConfiguration()
Returns
- KafkaProducerEndpointConfiguration
The endpoint.
ProduceTo(TopicPartition)
Specifies the target topic and partition.
public KafkaProducerEndpointConfigurationBuilder<TMessage> ProduceTo(TopicPartition topicPartition)
Parameters
topicPartitionTopicPartitionThe target topic and partition.
Returns
- 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.
public KafkaProducerEndpointConfigurationBuilder<TMessage> ProduceTo(Func<IOutboundEnvelope<TMessage>, TopicPartition> topicPartitionFunction)
Parameters
topicPartitionFunctionFunc<IOutboundEnvelope<TMessage>, TopicPartition>The function returning the target topic and partition index for the message being produced.
Returns
- 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.
public KafkaProducerEndpointConfigurationBuilder<TMessage> ProduceTo(Func<IOutboundEnvelope<TMessage>, string> topicFunction, Func<IOutboundEnvelope<TMessage>, int>? partitionFunction = null)
Parameters
topicFunctionFunc<IOutboundEnvelope<TMessage>, string>The function returning the target topic for the message being produced.
partitionFunctionFunc<IOutboundEnvelope<TMessage>, int>The optional function returning the target partition index for the message being produced. If
nullthe partition is automatically derived from the message key (use KafkaKeyMemberAttribute to specify a message key, otherwise a random one will be generated).
Returns
- 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.
public KafkaProducerEndpointConfigurationBuilder<TMessage> ProduceTo(Func<TMessage?, TopicPartition> topicPartitionFunction)
Parameters
topicPartitionFunctionFunc<TMessage, TopicPartition>The function returning the target topic and partition index for the message being produced.
Returns
- 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.
public KafkaProducerEndpointConfigurationBuilder<TMessage> ProduceTo(Func<TMessage?, string> topicFunction, Func<TMessage?, int>? partitionFunction = null)
Parameters
topicFunctionFunc<TMessage, string>The function returning the target topic for the message being produced.
partitionFunctionFunc<TMessage, int>The optional function returning the target partition index for the message being produced. If
nullthe partition is automatically derived from the message key (use KafkaKeyMemberAttribute to specify a message key, otherwise a random one will be generated).
Returns
- 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.
public KafkaProducerEndpointConfigurationBuilder<TMessage> ProduceTo(string topic, Func<IOutboundEnvelope<TMessage>, int> partitionFunction)
Parameters
topicstringThe target topic.
partitionFunctionFunc<IOutboundEnvelope<TMessage>, int>The function returning the target partition index for the message being produced.
Returns
- 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.
public KafkaProducerEndpointConfigurationBuilder<TMessage> ProduceTo(string topicFormatString, Func<IOutboundEnvelope<TMessage>, string[]> topicArgumentsFunction, Func<IOutboundEnvelope<TMessage>, int>? partitionFunction = null)
Parameters
topicFormatStringstringThe topic format string that will be combined with the arguments returned by the
topicArgumentsFunctionusing a Format(string, params object[]).topicArgumentsFunctionFunc<IOutboundEnvelope<TMessage>, string[]>The function returning the arguments to be used to format the string.
partitionFunctionFunc<IOutboundEnvelope<TMessage>, int>The optional function returning the target partition index for the message being produced. If
nullthe partition is automatically derived from the message key (use KafkaKeyMemberAttribute to specify a message key, otherwise a random one will be generated).
Returns
- 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.
public KafkaProducerEndpointConfigurationBuilder<TMessage> ProduceTo(string topic, Func<TMessage?, int> partitionFunction)
Parameters
topicstringThe target topic.
partitionFunctionFunc<TMessage, int>The function returning the target partition index for the message being produced.
Returns
- 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.
public KafkaProducerEndpointConfigurationBuilder<TMessage> ProduceTo(string topicFormatString, Func<TMessage?, string[]> topicArgumentsFunction, Func<TMessage?, int>? partitionFunction = null)
Parameters
topicFormatStringstringThe topic format string that will be combined with the arguments returned by the
topicArgumentsFunctionusing a Format(string, params object[]).topicArgumentsFunctionFunc<TMessage, string[]>The function returning the arguments to be used to format the string.
partitionFunctionFunc<TMessage, int>The optional function returning the target partition index for the message being produced. If
nullthe partition is automatically derived from the message key (use KafkaKeyMemberAttribute to specify a message key, otherwise a random one will be generated).
Returns
- KafkaProducerEndpointConfigurationBuilder<TMessage>
The KafkaProducerEndpointConfigurationBuilder<TMessage> so that additional calls can be chained.
ProduceTo(string, int?)
Specifies the target topic and optionally the target partition.
public KafkaProducerEndpointConfigurationBuilder<TMessage> ProduceTo(string topic, int? partition = null)
Parameters
topicstringThe target topic.
partitionint?The optional target partition index. If
nullthe partition is automatically derived from the message key (use KafkaKeyMemberAttribute to specify a message key, otherwise a random one will be generated).
Returns
- 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.
public KafkaProducerEndpointConfigurationBuilder<TMessage> ProduceToDynamicTopic()
Returns
- 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.
public KafkaProducerEndpointConfigurationBuilder<TMessage> SetKafkaKey(Func<IOutboundEnvelope<TMessage>, object?> valueProvider)
Parameters
valueProviderFunc<IOutboundEnvelope<TMessage>, object>The value provider function.
Returns
- 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.
public KafkaProducerEndpointConfigurationBuilder<TMessage> SetKafkaKey(Func<TMessage?, object?> valueProvider)
Parameters
Returns
- 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.
public KafkaProducerEndpointConfigurationBuilder<TMessage> SetKafkaKey<TMessageChildType>(Func<IOutboundEnvelope<TMessageChildType>, object?> valueProvider) where TMessageChildType : TMessage
Parameters
valueProviderFunc<IOutboundEnvelope<TMessageChildType>, object>The value provider function.
Returns
- KafkaProducerEndpointConfigurationBuilder<TMessage>
The KafkaProducerEndpointConfigurationBuilder<TMessage> so that additional calls can be chained.
Type Parameters
TMessageChildTypeThe 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.
public KafkaProducerEndpointConfigurationBuilder<TMessage> SetKafkaKey<TMessageChildType>(Func<TMessageChildType?, object?> valueProvider) where TMessageChildType : TMessage
Parameters
Returns
- KafkaProducerEndpointConfigurationBuilder<TMessage>
The KafkaProducerEndpointConfigurationBuilder<TMessage> so that additional calls can be chained.
Type Parameters
TMessageChildTypeThe 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.
public KafkaProducerEndpointConfigurationBuilder<TMessage> UseEndpointResolver<TResolver>() where TResolver : IKafkaProducerEndpointResolver<TMessage>
Returns
- KafkaProducerEndpointConfigurationBuilder<TMessage>
The KafkaProducerEndpointConfigurationBuilder<TMessage> so that additional calls can be chained.
Type Parameters
TResolverThe type of the IKafkaProducerEndpointResolver<TMessage> to be used.