Class KafkaProducerEndpoint
Represents a topic to produce to.
Inherited Members
Namespace: Silverback.Messaging
Assembly: Silverback.Integration.Kafka.dll
Syntax
public sealed class KafkaProducerEndpoint : ProducerEndpoint, IProducerEndpoint, IEndpoint, IEquatable<KafkaProducerEndpoint>
Constructors
| Improve this doc View sourceKafkaProducerEndpoint(Func<IOutboundEnvelope, IServiceProvider, string?>, KafkaClientConfig?)
Initializes a new instance of the KafkaProducerEndpoint class.
Declaration
public KafkaProducerEndpoint(Func<IOutboundEnvelope, IServiceProvider, string?> topicNameFunction, KafkaClientConfig? clientConfig = null)
Parameters
Type | Name | Description |
---|---|---|
Func<IOutboundEnvelope, IServiceProvider, string> | topicNameFunction | The function returning the topic name for the message being produced. If the function returns
|
KafkaClientConfig | clientConfig | The KafkaClientConfig to be used to initialize the KafkaProducerConfig. |
KafkaProducerEndpoint(Func<IOutboundEnvelope, IServiceProvider, string?>, Func<IOutboundEnvelope, IServiceProvider, int>?, KafkaClientConfig?)
Initializes a new instance of the KafkaProducerEndpoint class.
Declaration
public KafkaProducerEndpoint(Func<IOutboundEnvelope, IServiceProvider, string?> topicNameFunction, Func<IOutboundEnvelope, IServiceProvider, int>? partitionFunction, KafkaClientConfig? clientConfig = null)
Parameters
Type | Name | Description |
---|---|---|
Func<IOutboundEnvelope, IServiceProvider, string> | topicNameFunction | The function returning the topic name for the message being produced. If the function returns
|
Func<IOutboundEnvelope, IServiceProvider, int> | partitionFunction | The optional function returning the target partition index for the message being produced. If |
KafkaClientConfig | clientConfig | The KafkaClientConfig to be used to initialize the KafkaProducerConfig. |
KafkaProducerEndpoint(Func<IOutboundEnvelope, string?>, KafkaClientConfig?)
Initializes a new instance of the KafkaProducerEndpoint class.
Declaration
public KafkaProducerEndpoint(Func<IOutboundEnvelope, string?> topicNameFunction, KafkaClientConfig? clientConfig = null)
Parameters
Type | Name | Description |
---|---|---|
Func<IOutboundEnvelope, string> | topicNameFunction | The function returning the topic name for the message being produced. If the function returns
|
KafkaClientConfig | clientConfig | The KafkaClientConfig to be used to initialize the KafkaProducerConfig. |
KafkaProducerEndpoint(Func<IOutboundEnvelope, string?>, Func<IOutboundEnvelope, int>?, KafkaClientConfig?)
Initializes a new instance of the KafkaProducerEndpoint class.
Declaration
public KafkaProducerEndpoint(Func<IOutboundEnvelope, string?> topicNameFunction, Func<IOutboundEnvelope, int>? partitionFunction, KafkaClientConfig? clientConfig = null)
Parameters
Type | Name | Description |
---|---|---|
Func<IOutboundEnvelope, string> | topicNameFunction | The function returning the topic name for the message being produced. If the function returns
|
Func<IOutboundEnvelope, int> | partitionFunction | The optional function returning the target partition index for the message being produced. If |
KafkaClientConfig | clientConfig | The KafkaClientConfig to be used to initialize the KafkaProducerConfig. |
KafkaProducerEndpoint(string, KafkaClientConfig?)
Initializes a new instance of the KafkaProducerEndpoint class.
Declaration
public KafkaProducerEndpoint(string topicName, KafkaClientConfig? clientConfig = null)
Parameters
Type | Name | Description |
---|---|---|
string | topicName | The name of the topic. |
KafkaClientConfig | clientConfig | The KafkaClientConfig to be used to initialize the KafkaProducerConfig. |
KafkaProducerEndpoint(string, Func<IOutboundEnvelope, string[]>, KafkaClientConfig?)
Initializes a new instance of the KafkaProducerEndpoint class.
Declaration
public KafkaProducerEndpoint(string topicNameFormatString, Func<IOutboundEnvelope, string[]> topicNameArgumentsFunction, KafkaClientConfig? clientConfig = null)
Parameters
Type | Name | Description |
---|---|---|
string | topicNameFormatString | The endpoint name format string that will be combined with the arguments returned by the
|
Func<IOutboundEnvelope, string[]> | topicNameArgumentsFunction | The function returning the arguments to be used to format the string. |
KafkaClientConfig | clientConfig | The KafkaClientConfig to be used to initialize the KafkaProducerConfig. |
KafkaProducerEndpoint(string, Func<IOutboundEnvelope, string[]>, Func<IOutboundEnvelope, int>?, KafkaClientConfig?)
Initializes a new instance of the KafkaProducerEndpoint class.
Declaration
public KafkaProducerEndpoint(string topicNameFormatString, Func<IOutboundEnvelope, string[]> topicNameArgumentsFunction, Func<IOutboundEnvelope, int>? partitionFunction, KafkaClientConfig? clientConfig = null)
Parameters
Type | Name | Description |
---|---|---|
string | topicNameFormatString | The endpoint name format string that will be combined with the arguments returned by the
|
Func<IOutboundEnvelope, string[]> | topicNameArgumentsFunction | The function returning the arguments to be used to format the string. |
Func<IOutboundEnvelope, int> | partitionFunction | The optional function returning the target partition index for the message being produced. If |
KafkaClientConfig | clientConfig | The KafkaClientConfig to be used to initialize the KafkaProducerConfig. |
KafkaProducerEndpoint(string, int?, KafkaClientConfig?)
Initializes a new instance of the KafkaProducerEndpoint class.
Declaration
public KafkaProducerEndpoint(string topicName, int? partition, KafkaClientConfig? clientConfig = null)
Parameters
Type | Name | Description |
---|---|---|
string | topicName | The name of the topic. |
int? | partition | The optional partition index. If |
KafkaClientConfig | clientConfig | The KafkaClientConfig to be used to initialize the KafkaProducerConfig. |
KafkaProducerEndpoint(Type, KafkaClientConfig?)
Initializes a new instance of the KafkaProducerEndpoint class.
Declaration
public KafkaProducerEndpoint(Type resolverType, KafkaClientConfig? clientConfig = null)
Parameters
Type | Name | Description |
---|---|---|
Type | resolverType | The type of the IKafkaProducerEndpointNameResolver to be used to resolve the actual endpoint name. |
KafkaClientConfig | clientConfig | The KafkaClientConfig to be used to initialize the KafkaProducerConfig. |
Properties
| Improve this doc View sourceConfiguration
Gets or sets the Kafka client configuration. This is actually an extension of the configuration dictionary provided by the Confluent.Kafka library.
Declaration
public KafkaProducerConfig Configuration { get; set; }
Property Value
Type | Description |
---|---|
KafkaProducerConfig |
Methods
| Improve this doc View sourceEquals(KafkaProducerEndpoint?)
Indicates whether the current object is equal to another object of the same type.
Declaration
public bool Equals(KafkaProducerEndpoint? other)
Parameters
Type | Name | Description |
---|---|---|
KafkaProducerEndpoint | other | An object to compare with this object. |
Returns
Type | Description |
---|---|
bool | true if the current object is equal to the |
Equals(object?)
Determines whether the specified object is equal to the current object.
Declaration
public override bool Equals(object? obj)
Parameters
Type | Name | Description |
---|---|---|
object | obj | The object to compare with the current object. |
Returns
Type | Description |
---|---|
bool | true if the specified object is equal to the current object; otherwise, false. |
Overrides
| Improve this doc View sourceGetHashCode()
Serves as the default hash function.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int | A hash code for the current object. |
Overrides
| Improve this doc View sourceGetPartition(IOutboundEnvelope, IServiceProvider)
Gets the target partition. When set to Partition.Any
(-1) the partition is automatically
derived from the message key (use KafkaKeyMemberAttribute to specify a message key,
otherwise a random one will be generated).
The default is Partition.Any
(-1).
Declaration
public Partition GetPartition(IOutboundEnvelope envelope, IServiceProvider serviceProvider)
Parameters
Type | Name | Description |
---|---|---|
IOutboundEnvelope | envelope | The envelope containing the message being produced. |
IServiceProvider | serviceProvider | The IServiceProvider in the current scope. |
Returns
Type | Description |
---|---|
Partition | The partition to be produced to. |
Validate()
Validates the endpoint configuration and throws an EndpointConfigurationException if not valid.
Declaration
public override void Validate()