Table of Contents

Class KafkaDynamicProducerEndpointResolver<TMessage>

Namespace
Silverback.Messaging.Producing.EndpointResolvers
Assembly
Silverback.Integration.Kafka.dll

Dynamically resolves the target topic and partition for each message being produced.

public sealed record KafkaDynamicProducerEndpointResolver<TMessage> : DynamicProducerEndpointResolver<TMessage, KafkaProducerEndpoint, KafkaProducerEndpointConfiguration>, IDynamicProducerEndpointResolver<KafkaProducerEndpoint>, IDynamicProducerEndpointResolver, IProducerEndpointResolver<KafkaProducerEndpoint>, IProducerEndpointResolver, IEquatable<DynamicProducerEndpointResolver<TMessage, KafkaProducerEndpoint, KafkaProducerEndpointConfiguration>>, IEquatable<KafkaDynamicProducerEndpointResolver<TMessage>> where TMessage : class

Type Parameters

TMessage

The type of the message being produced.

Inheritance
KafkaDynamicProducerEndpointResolver<TMessage>
Implements
Inherited Members

Constructors

KafkaDynamicProducerEndpointResolver(Func<IOutboundEnvelope<TMessage>, TopicPartition>)

Initializes a new instance of the KafkaDynamicProducerEndpointResolver<TMessage> class.

public KafkaDynamicProducerEndpointResolver(Func<IOutboundEnvelope<TMessage>, TopicPartition> topicPartitionFunction)

Parameters

topicPartitionFunction Func<IOutboundEnvelope<TMessage>, TopicPartition>

The function returning the target topic and partition index for the message being produced.

KafkaDynamicProducerEndpointResolver(Func<IOutboundEnvelope<TMessage>, string>)

Initializes a new instance of the KafkaDynamicProducerEndpointResolver<TMessage> class.

public KafkaDynamicProducerEndpointResolver(Func<IOutboundEnvelope<TMessage>, string> topicFunction)

Parameters

topicFunction Func<IOutboundEnvelope<TMessage>, string>

The function returning the target topic for the message being produced.

KafkaDynamicProducerEndpointResolver(Func<IOutboundEnvelope<TMessage>, string>, Func<IOutboundEnvelope<TMessage>, int>)

Initializes a new instance of the KafkaDynamicProducerEndpointResolver<TMessage> class.

public KafkaDynamicProducerEndpointResolver(Func<IOutboundEnvelope<TMessage>, string> topicFunction, Func<IOutboundEnvelope<TMessage>, int> partitionFunction)

Parameters

topicFunction Func<IOutboundEnvelope<TMessage>, string>

The function returning the target topic for the message being produced.

partitionFunction Func<IOutboundEnvelope<TMessage>, int>

The function returning the target partition index for the message being produced.

KafkaDynamicProducerEndpointResolver(Func<TMessage?, TopicPartition>)

Initializes a new instance of the KafkaDynamicProducerEndpointResolver<TMessage> class.

public KafkaDynamicProducerEndpointResolver(Func<TMessage?, TopicPartition> topicPartitionFunction)

Parameters

topicPartitionFunction Func<TMessage, TopicPartition>

The function returning the target topic and partition index for the message being produced.

KafkaDynamicProducerEndpointResolver(Func<TMessage?, string>)

Initializes a new instance of the KafkaDynamicProducerEndpointResolver<TMessage> class.

public KafkaDynamicProducerEndpointResolver(Func<TMessage?, string> topicFunction)

Parameters

topicFunction Func<TMessage, string>

The function returning the target topic for the message being produced.

KafkaDynamicProducerEndpointResolver(Func<TMessage?, string>, Func<TMessage?, int>)

Initializes a new instance of the KafkaDynamicProducerEndpointResolver<TMessage> class.

public KafkaDynamicProducerEndpointResolver(Func<TMessage?, string> topicFunction, Func<TMessage?, int> partitionFunction)

Parameters

topicFunction Func<TMessage, string>

The function returning the target topic for the message being produced.

partitionFunction Func<TMessage, int>

The function returning the target partition index for the message being produced.

KafkaDynamicProducerEndpointResolver(string, Func<IOutboundEnvelope<TMessage>, int>)

Initializes a new instance of the KafkaDynamicProducerEndpointResolver<TMessage> class.

public KafkaDynamicProducerEndpointResolver(string topic, Func<IOutboundEnvelope<TMessage>, int> partitionFunction)

Parameters

topic string

The target topic.

partitionFunction Func<IOutboundEnvelope<TMessage>, int>

The function returning the target partition index for the message being produced.

KafkaDynamicProducerEndpointResolver(string, Func<IOutboundEnvelope<TMessage>, string[]>, Func<IOutboundEnvelope<TMessage>, int>?)

Initializes a new instance of the KafkaDynamicProducerEndpointResolver<TMessage> class.

public KafkaDynamicProducerEndpointResolver(string topicFormatString, Func<IOutboundEnvelope<TMessage>, string[]> topicArgumentsFunction, Func<IOutboundEnvelope<TMessage>, int>? partitionFunction = null)

Parameters

topicFormatString string

The topic format string that will be combined with the arguments returned by the topicArgumentsFunction using a Format(string, params object[]).

topicArgumentsFunction Func<IOutboundEnvelope<TMessage>, string[]>

The function returning the arguments to be used to format the string.

partitionFunction Func<IOutboundEnvelope<TMessage>, int>

The optional function returning the target partition index for the message being produced. If null the partition is automatically derived from the message key (use KafkaKeyMemberAttribute to specify a message key, otherwise a random one will be generated).

KafkaDynamicProducerEndpointResolver(string, Func<TMessage?, int>)

Initializes a new instance of the KafkaDynamicProducerEndpointResolver<TMessage> class.

public KafkaDynamicProducerEndpointResolver(string topic, Func<TMessage?, int> partitionFunction)

Parameters

topic string

The target topic.

partitionFunction Func<TMessage, int>

The function returning the target partition index for the message being produced.

KafkaDynamicProducerEndpointResolver(string, Func<TMessage?, string[]>, Func<TMessage?, int>?)

Initializes a new instance of the KafkaDynamicProducerEndpointResolver<TMessage> class.

public KafkaDynamicProducerEndpointResolver(string topicFormatString, Func<TMessage?, string[]> topicArgumentsFunction, Func<TMessage?, int>? partitionFunction = null)

Parameters

topicFormatString string

The topic format string that will be combined with the arguments returned by the topicArgumentsFunction using a Format(string, params object[]).

topicArgumentsFunction Func<TMessage, string[]>

The function returning the arguments to be used to format the string.

partitionFunction Func<TMessage, int>

The optional function returning the target partition index for the message being produced. If null the partition is automatically derived from the message key (use KafkaKeyMemberAttribute to specify a message key, otherwise a random one will be generated).

Properties

EqualityContract

protected override Type EqualityContract { get; }

Property Value

Type

Methods

DeserializeEndpoint(string, KafkaProducerEndpointConfiguration)

Deserializes the endpoint from a string.

protected override KafkaProducerEndpoint DeserializeEndpoint(string serializedEndpoint, KafkaProducerEndpointConfiguration configuration)

Parameters

serializedEndpoint string

The serialized endpoint.

configuration KafkaProducerEndpointConfiguration

The endpoint configuration.

Returns

KafkaProducerEndpoint

The deserialized endpoint.

Equals(DynamicProducerEndpointResolver<TMessage, KafkaProducerEndpoint, KafkaProducerEndpointConfiguration>?)

public override sealed bool Equals(DynamicProducerEndpointResolver<TMessage, KafkaProducerEndpoint, KafkaProducerEndpointConfiguration>? other)

Parameters

other DynamicProducerEndpointResolver<TMessage, KafkaProducerEndpoint, KafkaProducerEndpointConfiguration>

Returns

bool

Equals(KafkaDynamicProducerEndpointResolver<TMessage>?)

public bool Equals(KafkaDynamicProducerEndpointResolver<TMessage>? other)

Parameters

other KafkaDynamicProducerEndpointResolver<TMessage>

Returns

bool

Equals(object?)

public override bool Equals(object? obj)

Parameters

obj object

Returns

bool

GetEndpointCore(IOutboundEnvelope<TMessage>, KafkaProducerEndpointConfiguration)

Gets the computed actual destination endpoint for the message being produced.

protected override KafkaProducerEndpoint GetEndpointCore(IOutboundEnvelope<TMessage> envelope, KafkaProducerEndpointConfiguration configuration)

Parameters

envelope IOutboundEnvelope<TMessage>

The envelope containing the message to be produced.

configuration KafkaProducerEndpointConfiguration

The endpoint configuration.

Returns

KafkaProducerEndpoint

The ProducerEndpoint for the specified message.

GetHashCode()

public override int GetHashCode()

Returns

int

PrintMembers(StringBuilder)

protected override bool PrintMembers(StringBuilder builder)

Parameters

builder StringBuilder

Returns

bool

SerializeEndpoint(KafkaProducerEndpoint)

Serializes the endpoint to a string.

protected override string SerializeEndpoint(KafkaProducerEndpoint endpoint)

Parameters

endpoint KafkaProducerEndpoint

The endpoint to be serialized.

Returns

string

The serialized endpoint.

ToString()

public override string ToString()

Returns

string

Operators

operator ==(KafkaDynamicProducerEndpointResolver<TMessage>?, KafkaDynamicProducerEndpointResolver<TMessage>?)

public static bool operator ==(KafkaDynamicProducerEndpointResolver<TMessage>? left, KafkaDynamicProducerEndpointResolver<TMessage>? right)

Parameters

left KafkaDynamicProducerEndpointResolver<TMessage>
right KafkaDynamicProducerEndpointResolver<TMessage>

Returns

bool

operator !=(KafkaDynamicProducerEndpointResolver<TMessage>?, KafkaDynamicProducerEndpointResolver<TMessage>?)

public static bool operator !=(KafkaDynamicProducerEndpointResolver<TMessage>? left, KafkaDynamicProducerEndpointResolver<TMessage>? right)

Parameters

left KafkaDynamicProducerEndpointResolver<TMessage>
right KafkaDynamicProducerEndpointResolver<TMessage>

Returns

bool