confluent-kafka-dotnet
Show / Hide Table of Contents

Class ProducerConfig

Producer configuration properties

Inheritance
object
Config
ClientConfig
ProducerConfig
Implements
IEnumerable<KeyValuePair<string, string>>
IEnumerable
Inherited Members
ClientConfig.SaslMechanism
ClientConfig.Acks
ClientConfig.ClientId
ClientConfig.BootstrapServers
ClientConfig.MessageMaxBytes
ClientConfig.MessageCopyMaxBytes
ClientConfig.ReceiveMessageMaxBytes
ClientConfig.MaxInFlight
ClientConfig.TopicMetadataRefreshIntervalMs
ClientConfig.MetadataMaxAgeMs
ClientConfig.TopicMetadataRefreshFastIntervalMs
ClientConfig.TopicMetadataRefreshSparse
ClientConfig.TopicMetadataPropagationMaxMs
ClientConfig.TopicBlacklist
ClientConfig.Debug
ClientConfig.SocketTimeoutMs
ClientConfig.SocketSendBufferBytes
ClientConfig.SocketReceiveBufferBytes
ClientConfig.SocketKeepaliveEnable
ClientConfig.SocketNagleDisable
ClientConfig.SocketMaxFails
ClientConfig.BrokerAddressTtl
ClientConfig.BrokerAddressFamily
ClientConfig.SocketConnectionSetupTimeoutMs
ClientConfig.ConnectionsMaxIdleMs
ClientConfig.ReconnectBackoffMs
ClientConfig.ReconnectBackoffMaxMs
ClientConfig.StatisticsIntervalMs
ClientConfig.LogQueue
ClientConfig.LogThreadName
ClientConfig.EnableRandomSeed
ClientConfig.LogConnectionClose
ClientConfig.InternalTerminationSignal
ClientConfig.ApiVersionRequest
ClientConfig.ApiVersionRequestTimeoutMs
ClientConfig.ApiVersionFallbackMs
ClientConfig.BrokerVersionFallback
ClientConfig.AllowAutoCreateTopics
ClientConfig.SecurityProtocol
ClientConfig.SslCipherSuites
ClientConfig.SslCurvesList
ClientConfig.SslSigalgsList
ClientConfig.SslKeyLocation
ClientConfig.SslKeyPassword
ClientConfig.SslKeyPem
ClientConfig.SslCertificateLocation
ClientConfig.SslCertificatePem
ClientConfig.SslCaLocation
ClientConfig.SslCaPem
ClientConfig.SslCaCertificateStores
ClientConfig.SslCrlLocation
ClientConfig.SslKeystoreLocation
ClientConfig.SslKeystorePassword
ClientConfig.SslProviders
ClientConfig.SslEngineLocation
ClientConfig.SslEngineId
ClientConfig.EnableSslCertificateVerification
ClientConfig.SslEndpointIdentificationAlgorithm
ClientConfig.SaslKerberosServiceName
ClientConfig.SaslKerberosPrincipal
ClientConfig.SaslKerberosKinitCmd
ClientConfig.SaslKerberosKeytab
ClientConfig.SaslKerberosMinTimeBeforeRelogin
ClientConfig.SaslUsername
ClientConfig.SaslPassword
ClientConfig.SaslOauthbearerConfig
ClientConfig.EnableSaslOauthbearerUnsecureJwt
ClientConfig.SaslOauthbearerMethod
ClientConfig.SaslOauthbearerClientId
ClientConfig.SaslOauthbearerClientSecret
ClientConfig.SaslOauthbearerScope
ClientConfig.SaslOauthbearerExtensions
ClientConfig.SaslOauthbearerTokenEndpointUrl
ClientConfig.PluginLibraryPaths
ClientConfig.ClientRack
ClientConfig.RetryBackoffMs
ClientConfig.RetryBackoffMaxMs
ClientConfig.ClientDnsLookup
ClientConfig.EnableMetricsPush
Config.Set(string, string)
Config.Get(string)
Config.GetInt(string)
Config.GetBool(string)
Config.GetDouble(string)
Config.GetEnum(Type, string)
Config.SetObject(string, object)
Config.properties
Config.GetEnumerator()
Config.CancellationDelayMaxMs
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: Confluent.Kafka
Assembly: Confluent.Kafka.dll
Syntax
public class ProducerConfig : ClientConfig, IEnumerable<KeyValuePair<string, string>>, IEnumerable

Constructors

ProducerConfig()

Initialize a new empty ProducerConfig instance.

Declaration
public ProducerConfig()

ProducerConfig(ClientConfig)

Initialize a new ProducerConfig instance wrapping an existing ClientConfig instance. This will change the values "in-place" i.e. operations on this class WILL modify the provided collection

Declaration
public ProducerConfig(ClientConfig config)
Parameters
Type Name Description
ClientConfig config

ProducerConfig(IDictionary<string, string>)

Initialize a new ProducerConfig instance wrapping an existing key/value pair collection. This will change the values "in-place" i.e. operations on this class WILL modify the provided collection

Declaration
public ProducerConfig(IDictionary<string, string> config)
Parameters
Type Name Description
IDictionary<string, string> config

Properties

BatchNumMessages

Maximum number of messages batched in one MessageSet. The total MessageSet size is also limited by batch.size and message.max.bytes.

default: 10000 importance: medium

Declaration
public int? BatchNumMessages { get; set; }
Property Value
Type Description
int?

BatchSize

Maximum size (in bytes) of all messages batched in one MessageSet, including protocol framing overhead. This limit is applied after the first message has been added to the batch, regardless of the first message's size, this is to ensure that messages that exceed batch.size are produced. The total MessageSet size is also limited by batch.num.messages and message.max.bytes.

default: 1000000 importance: medium

Declaration
public int? BatchSize { get; set; }
Property Value
Type Description
int?

CompressionLevel

Compression level parameter for algorithm selected by configuration property compression.codec. Higher values will result in better compression at the cost of more CPU usage. Usable range is algorithm-dependent: [0-9] for gzip; [0-12] for lz4; only 0 for snappy; -1 = codec-dependent default compression level.

default: -1 importance: medium

Declaration
public int? CompressionLevel { get; set; }
Property Value
Type Description
int?

CompressionType

compression codec to use for compressing message sets. This is the default value for all topics, may be overridden by the topic configuration property compression.codec.

default: none importance: medium

Declaration
public CompressionType? CompressionType { get; set; }
Property Value
Type Description
CompressionType?

DeliveryReportFields

A comma separated list of fields that may be optionally set in delivery reports. Disabling delivery report fields that you do not require will improve maximum throughput and reduce memory usage. Allowed values: key, value, timestamp, headers, status, all, none.

default: all importance: low

Declaration
public string DeliveryReportFields { get; set; }
Property Value
Type Description
string

EnableBackgroundPoll

Specifies whether or not the producer should start a background poll thread to receive delivery reports and event notifications. Generally, this should be set to true. If set to false, you will need to call the Poll function manually.

default: true importance: low

Declaration
public bool? EnableBackgroundPoll { get; set; }
Property Value
Type Description
bool?

EnableDeliveryReports

Specifies whether to enable notification of delivery reports. Typically you should set this parameter to true. Set it to false for "fire and forget" semantics and a small boost in performance.

default: true importance: low

Declaration
public bool? EnableDeliveryReports { get; set; }
Property Value
Type Description
bool?

EnableGaplessGuarantee

EXPERIMENTAL: subject to change or removal. When set to true, any error that could result in a gap in the produced message series when a batch of messages fails, will raise a fatal error (ERR__GAPLESS_GUARANTEE) and stop the producer. Messages failing due to message.timeout.ms are not covered by this guarantee. Requires enable.idempotence=true.

default: false importance: low

Declaration
public bool? EnableGaplessGuarantee { get; set; }
Property Value
Type Description
bool?

EnableIdempotence

When set to true, the producer will ensure that messages are successfully produced exactly once and in the original produce order. The following configuration properties are adjusted automatically (if not modified by the user) when idempotence is enabled: max.in.flight.requests.per.connection=5 (must be less than or equal to 5), retries=INT32_MAX (must be greater than 0), acks=all, queuing.strategy=fifo. Producer instantation will fail if user-supplied configuration is incompatible.

default: false importance: high

Declaration
public bool? EnableIdempotence { get; set; }
Property Value
Type Description
bool?

LingerMs

Delay in milliseconds to wait for messages in the producer queue to accumulate before constructing message batches (MessageSets) to transmit to brokers. A higher value allows larger and more effective (less overhead, improved compression) batches of messages to accumulate at the expense of increased message delivery latency.

default: 5 importance: high

Declaration
public double? LingerMs { get; set; }
Property Value
Type Description
double?

MessageSendMaxRetries

How many times to retry sending a failing Message. Note: retrying may cause reordering unless enable.idempotence is set to true.

default: 2147483647 importance: high

Declaration
public int? MessageSendMaxRetries { get; set; }
Property Value
Type Description
int?

MessageTimeoutMs

Local message timeout. This value is only enforced locally and limits the time a produced message waits for successful delivery. A time of 0 is infinite. This is the maximum time librdkafka may use to deliver a message (including retries). Delivery error occurs when either the retry count or the message timeout are exceeded. The message timeout is automatically adjusted to transaction.timeout.ms if transactional.id is configured.

default: 300000 importance: high

Declaration
public int? MessageTimeoutMs { get; set; }
Property Value
Type Description
int?

Partitioner

Partitioner: random - random distribution, consistent - CRC32 hash of key (Empty and NULL keys are mapped to single partition), consistent_random - CRC32 hash of key (Empty and NULL keys are randomly partitioned), murmur2 - Java Producer compatible Murmur2 hash of key (NULL keys are mapped to single partition), murmur2_random - Java Producer compatible Murmur2 hash of key (NULL keys are randomly partitioned. This is functionally equivalent to the default partitioner in the Java Producer.), fnv1a - FNV-1a hash of key (NULL keys are mapped to single partition), fnv1a_random - FNV-1a hash of key (NULL keys are randomly partitioned).

default: consistent_random importance: high

Declaration
public Partitioner? Partitioner { get; set; }
Property Value
Type Description
Partitioner?

QueueBufferingBackpressureThreshold

The threshold of outstanding not yet transmitted broker requests needed to backpressure the producer's message accumulator. If the number of not yet transmitted requests equals or exceeds this number, produce request creation that would have otherwise been triggered (for example, in accordance with linger.ms) will be delayed. A lower number yields larger and more effective batches. A higher value can improve latency when using compression on slow machines.

default: 1 importance: low

Declaration
public int? QueueBufferingBackpressureThreshold { get; set; }
Property Value
Type Description
int?

QueueBufferingMaxKbytes

Maximum total message size sum allowed on the producer queue. This queue is shared by all topics and partitions. This property has higher priority than queue.buffering.max.messages.

default: 1048576 importance: high

Declaration
public int? QueueBufferingMaxKbytes { get; set; }
Property Value
Type Description
int?

QueueBufferingMaxMessages

Maximum number of messages allowed on the producer queue. This queue is shared by all topics and partitions. A value of 0 disables this limit.

default: 100000 importance: high

Declaration
public int? QueueBufferingMaxMessages { get; set; }
Property Value
Type Description
int?

RequestTimeoutMs

The ack timeout of the producer request in milliseconds. This value is only enforced by the broker and relies on request.required.acks being != 0.

default: 30000 importance: medium

Declaration
public int? RequestTimeoutMs { get; set; }
Property Value
Type Description
int?

StickyPartitioningLingerMs

Delay in milliseconds to wait to assign new sticky partitions for each topic. By default, set to double the time of linger.ms. To disable sticky behavior, set to 0. This behavior affects messages with the key NULL in all cases, and messages with key lengths of zero when the consistent_random partitioner is in use. These messages would otherwise be assigned randomly. A higher value allows for more effective batching of these messages.

default: 10 importance: low

Declaration
public int? StickyPartitioningLingerMs { get; set; }
Property Value
Type Description
int?

TransactionTimeoutMs

The maximum amount of time in milliseconds that the transaction coordinator will wait for a transaction status update from the producer before proactively aborting the ongoing transaction. If this value is larger than the transaction.max.timeout.ms setting in the broker, the init_transactions() call will fail with ERR_INVALID_TRANSACTION_TIMEOUT. The transaction timeout automatically adjusts message.timeout.ms and socket.timeout.ms, unless explicitly configured in which case they must not exceed the transaction timeout (socket.timeout.ms must be at least 100ms lower than transaction.timeout.ms). This is also the default timeout value if no timeout (-1) is supplied to the transactional API methods.

default: 60000 importance: medium

Declaration
public int? TransactionTimeoutMs { get; set; }
Property Value
Type Description
int?

TransactionalId

Enables the transactional producer. The transactional.id is used to identify the same transactional producer instance across process restarts. It allows the producer to guarantee that transactions corresponding to earlier instances of the same producer have been finalized prior to starting any new transactions, and that any zombie instances are fenced off. If no transactional.id is provided, then the producer is limited to idempotent delivery (if enable.idempotence is set). Requires broker version >= 0.11.0.

default: '' importance: high

Declaration
public string TransactionalId { get; set; }
Property Value
Type Description
string

Methods

ThrowIfContainsNonUserConfigurable()

Check if any properties have been set that have implications for application logic and therefore shouldn't be set via external configuration, independent of the code. Throw an ArgumentException if so.

There are currently no such Producer configuration properties and this method will never throw.

Declaration
public ProducerConfig ThrowIfContainsNonUserConfigurable()
Returns
Type Description
ProducerConfig

Implements

IEnumerable<T>
IEnumerable
In this article