Class KafkaProducerEndpointBuilder
Builds the KafkaProducerEndpoint.
Inheritance
Implements
Inherited Members
Namespace: Silverback.Messaging.Configuration.Kafka
Assembly: Silverback.Integration.Kafka.dll
Syntax
public class KafkaProducerEndpointBuilder : ProducerEndpointBuilder<KafkaProducerEndpoint, IKafkaProducerEndpointBuilder>, IKafkaProducerEndpointBuilder, IProducerEndpointBuilder<IKafkaProducerEndpointBuilder>, IEndpointBuilder<IKafkaProducerEndpointBuilder>
Constructors
| Improve this doc View sourceKafkaProducerEndpointBuilder(KafkaClientConfig, Type, IEndpointsConfigurationBuilder)
Initializes a new instance of the KafkaProducerEndpointBuilder class.
Declaration
public KafkaProducerEndpointBuilder(KafkaClientConfig clientConfig = null, Type messageType = null, IEndpointsConfigurationBuilder endpointsConfigurationBuilder = null)
Parameters
Type | Name | Description |
---|---|---|
KafkaClientConfig | clientConfig | The KafkaClientConfig to be used to initialize the KafkaProducerConfig. |
System.Type | messageType | The type of the message being produced. |
IEndpointsConfigurationBuilder | endpointsConfigurationBuilder | The optional reference to the IEndpointsConfigurationBuilder that instantiated the builder. |
Properties
| Improve this doc View sourceThis
Gets this instance.
Declaration
protected override IKafkaProducerEndpointBuilder This { get; }
Property Value
Type | Description |
---|---|
IKafkaProducerEndpointBuilder |
Overrides
Remarks
This is necessary to work around casting in the base classes.
Methods
| Improve this doc View sourceConfigure(Action<KafkaProducerConfig>)
Configures the Kafka client properties.
Declaration
public IKafkaProducerEndpointBuilder Configure(Action<KafkaProducerConfig> configAction)
Parameters
Type | Name | Description |
---|---|---|
System.Action<KafkaProducerConfig> | configAction | An System.Action<T> that takes the KafkaProducerConfig and configures it. |
Returns
Type | Description |
---|---|
IKafkaProducerEndpointBuilder | The IKafkaProducerEndpointBuilder so that additional calls can be chained. |
CreateEndpoint()
Creates the endpoint to be configured according to the options stored in the builder.
Declaration
protected override KafkaProducerEndpoint CreateEndpoint()
Returns
Type | Description |
---|---|
KafkaProducerEndpoint | The endpoint. |
Overrides
ProduceTo(Func<IOutboundEnvelope, IServiceProvider, String>, Func<IOutboundEnvelope, IServiceProvider, Int32>)
Specifies the name of the topic and optionally the target partition.
Declaration
public IKafkaProducerEndpointBuilder ProduceTo(Func<IOutboundEnvelope, IServiceProvider, string> topicNameFunction, Func<IOutboundEnvelope, IServiceProvider, int> partitionFunction = null)
Parameters
Type | Name | Description |
---|---|---|
System.Func<IOutboundEnvelope, System.IServiceProvider, System.String> | topicNameFunction | The function returning the topic name for the message being produced. If the function returns
|
System.Func<IOutboundEnvelope, System.IServiceProvider, System.Int32> | partitionFunction | The optional function returning the target partition index for the message being produced. If |
Returns
Type | Description |
---|---|
IKafkaProducerEndpointBuilder | The IKafkaProducerEndpointBuilder so that additional calls can be chained. |
ProduceTo(Func<IOutboundEnvelope, String>, Func<IOutboundEnvelope, Int32>)
Specifies the name of the topic and optionally the target partition.
Declaration
public IKafkaProducerEndpointBuilder ProduceTo(Func<IOutboundEnvelope, string> topicNameFunction, Func<IOutboundEnvelope, int> partitionFunction = null)
Parameters
Type | Name | Description |
---|---|---|
System.Func<IOutboundEnvelope, System.String> | topicNameFunction | The function returning the topic name for the message being produced. If the function returns
|
System.Func<IOutboundEnvelope, System.Int32> | partitionFunction | The optional function returning the target partition index for the message being produced. If |
Returns
Type | Description |
---|---|
IKafkaProducerEndpointBuilder | The IKafkaProducerEndpointBuilder so that additional calls can be chained. |
ProduceTo(String, Func<IOutboundEnvelope, String[]>, Func<IOutboundEnvelope, Int32>)
Specifies the name of the topic and optionally the target partition.
Declaration
public IKafkaProducerEndpointBuilder ProduceTo(string topicNameFormatString, Func<IOutboundEnvelope, string[]> topicNameArgumentsFunction, Func<IOutboundEnvelope, int> partitionFunction = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | topicNameFormatString | The endpoint name format string that will be combined with the arguments returned by the
|
System.Func<IOutboundEnvelope, System.String[]> | topicNameArgumentsFunction | The function returning the arguments to be used to format the string. |
System.Func<IOutboundEnvelope, System.Int32> | partitionFunction | The optional function returning the target partition index for the message being produced. If |
Returns
Type | Description |
---|---|
IKafkaProducerEndpointBuilder | The IKafkaProducerEndpointBuilder so that additional calls can be chained. |
ProduceTo(String, Nullable<Int32>)
Specifies the name of the topic and optionally the target partition.
Declaration
public IKafkaProducerEndpointBuilder ProduceTo(string topicName, int? partition = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | topicName | The name of the topic. |
System.Nullable<System.Int32> | partition | The optional partition index. If |
Returns
Type | Description |
---|---|
IKafkaProducerEndpointBuilder | The IKafkaProducerEndpointBuilder so that additional calls can be chained. |
ProduceTo<TMessage>(Func<IOutboundEnvelope<TMessage>, IServiceProvider, String>, Func<IOutboundEnvelope<TMessage>, IServiceProvider, Int32>)
Specifies the name of the topic and optionally the target partition.
Declaration
public IKafkaProducerEndpointBuilder ProduceTo<TMessage>(Func<IOutboundEnvelope<TMessage>, IServiceProvider, string> topicNameFunction, Func<IOutboundEnvelope<TMessage>, IServiceProvider, int> partitionFunction = null)
where TMessage : class
Parameters
Type | Name | Description |
---|---|---|
System.Func<IOutboundEnvelope<TMessage>, System.IServiceProvider, System.String> | topicNameFunction | The function returning the topic name for the message being produced. If the function returns
|
System.Func<IOutboundEnvelope<TMessage>, System.IServiceProvider, System.Int32> | partitionFunction | The optional function returning the target partition index for the message being produced. If |
Returns
Type | Description |
---|---|
IKafkaProducerEndpointBuilder | The IKafkaProducerEndpointBuilder so that additional calls can be chained. |
Type Parameters
Name | Description |
---|---|
TMessage | The type of the messages being produced. |
ProduceTo<TMessage>(Func<IOutboundEnvelope<TMessage>, String>, Func<IOutboundEnvelope<TMessage>, Int32>)
Specifies the name of the topic and optionally the target partition.
Declaration
public IKafkaProducerEndpointBuilder ProduceTo<TMessage>(Func<IOutboundEnvelope<TMessage>, string> topicNameFunction, Func<IOutboundEnvelope<TMessage>, int> partitionFunction = null)
where TMessage : class
Parameters
Type | Name | Description |
---|---|---|
System.Func<IOutboundEnvelope<TMessage>, System.String> | topicNameFunction | The function returning the topic name for the message being produced. If the function returns
|
System.Func<IOutboundEnvelope<TMessage>, System.Int32> | partitionFunction | The optional function returning the target partition index for the message being produced. If |
Returns
Type | Description |
---|---|
IKafkaProducerEndpointBuilder | The IKafkaProducerEndpointBuilder so that additional calls can be chained. |
Type Parameters
Name | Description |
---|---|
TMessage | The type of the messages being produced. |
ProduceTo<TMessage>(String, Func<IOutboundEnvelope<TMessage>, String[]>, Func<IOutboundEnvelope<TMessage>, Int32>)
Specifies the name of the topic and optionally the target partition.
Declaration
public IKafkaProducerEndpointBuilder ProduceTo<TMessage>(string topicNameFormatString, Func<IOutboundEnvelope<TMessage>, string[]> topicNameArgumentsFunction, Func<IOutboundEnvelope<TMessage>, int> partitionFunction = null)
where TMessage : class
Parameters
Type | Name | Description |
---|---|---|
System.String | topicNameFormatString | The endpoint name format string that will be combined with the arguments returned by the
|
System.Func<IOutboundEnvelope<TMessage>, System.String[]> | topicNameArgumentsFunction | The function returning the arguments to be used to format the string. |
System.Func<IOutboundEnvelope<TMessage>, System.Int32> | partitionFunction | The optional function returning the target partition index for the message being produced. If |
Returns
Type | Description |
---|---|
IKafkaProducerEndpointBuilder | The IKafkaProducerEndpointBuilder so that additional calls can be chained. |
Type Parameters
Name | Description |
---|---|
TMessage | The type of the messages being produced. |
UseEndpointNameResolver<TResolver>()
Specifies the type of the IKafkaProducerEndpointNameResolver to be used to resolve the actual endpoint name and partition.
Declaration
public IKafkaProducerEndpointBuilder UseEndpointNameResolver<TResolver>()
where TResolver : IKafkaProducerEndpointNameResolver
Returns
Type | Description |
---|---|
IKafkaProducerEndpointBuilder | The IKafkaProducerEndpointBuilder so that additional calls can be chained. |
Type Parameters
Name | Description |
---|---|
TResolver | The type of the IKafkaProducerEndpointNameResolver to be used. |
WithKafkaKey<TMessage>(Func<IOutboundEnvelope<TMessage>, Object>)
Uses the specified value provider function to set the kafka key for each produced message.
Declaration
public IKafkaProducerEndpointBuilder WithKafkaKey<TMessage>(Func<IOutboundEnvelope<TMessage>, object> valueProvider)
where TMessage : class
Parameters
Type | Name | Description |
---|---|---|
System.Func<IOutboundEnvelope<TMessage>, System.Object> | valueProvider | The value provider function. |
Returns
Type | Description |
---|---|
IKafkaProducerEndpointBuilder | The endpoint builder so that additional calls can be chained. |
Type Parameters
Name | Description |
---|---|
TMessage | The type of the messages to be enriched. |