Class KafkaConnectionFactory

Namespace: redb.Route.Kafka
Assembly: redb.Route.Kafka.dll

Connection factory for Kafka. Register via DI or in the route registry
and reference by name in endpoint URIs (connectionFactory=myFactory).
Centralises broker addresses and security settings so they can be shared
across multiple Kafka endpoints without duplicating URI parameters.

public sealed class KafkaConnectionFactory

Inheritance

Object→KafkaConnectionFactory

Properties

Acks

Default acknowledgment level: None, Leader, All. Default All, as in the Kafka 3 client and Camel 4.

public string Acks { get; set; }

AdditionalProperties

Additional librdkafka properties not exposed as typed settings.

public Dictionary<string, string> AdditionalProperties { get; set; }

AutoOffsetReset

Default auto-offset reset: Latest, Earliest, Error.

public string AutoOffsetReset { get; set; }

BatchSize

Max batch size in bytes (default: 1000000).

public int? BatchSize { get; set; }

Brokers

Comma-separated list of Kafka broker addresses (e.g., "broker1:9092,broker2:9092").

public string Brokers { get; set; }

ClientId

Client ID for broker identification.

public string ClientId { get; set; }

CompressionType

Compression type: None, Gzip, Snappy, Lz4, Zstd.

public string? CompressionType { get; set; }

GroupId

Default consumer group ID.

public string? GroupId { get; set; }

GroupInstanceId

Static group instance ID for consumer. Avoids rebalance storms during rolling deploys (K8s).

public string? GroupInstanceId { get; set; }

HeartbeatIntervalMs

Consumer heartbeat interval in ms (default: 3000). Should be < SessionTimeoutMs/3.

public int? HeartbeatIntervalMs { get; set; }

IsolationLevel

Isolation level: ReadUncommitted, ReadCommitted. ReadCommitted hides records of aborted

public string? IsolationLevel { get; set; }

LingerMs

Batching delay in ms (default: 5). Higher = more batching. 0 = no batching.

public int? LingerMs { get; set; }

MaxInFlight

Max in-flight requests per connection (default: 5). Set to 1 for strict ordering.

public int MaxInFlight { get; set; }

MaxPollIntervalMs

Max time between polls in ms (default: 300000). Prevents endless processing from triggering rebalance.

public int? MaxPollIntervalMs { get; set; }

MessageTimeoutMs

Total delivery timeout in ms (default: 120000). Includes retries.

public int? MessageTimeoutMs { get; set; }

MetadataMaxAgeMs

Metadata max age in ms before refresh (default: 300000).

public int MetadataMaxAgeMs { get; set; }

PartitionAssignmentStrategy

Partition assignment strategy: Range, RoundRobin, CooperativeSticky. CooperativeSticky avoids stop-the-world rebalance.

public string? PartitionAssignmentStrategy { get; set; }

ReconnectBackoffMaxMs

Reconnect backoff max in ms (default: 10000).

public int? ReconnectBackoffMaxMs { get; set; }

ReconnectBackoffMs

Reconnect backoff initial in ms (default: 100).

public int? ReconnectBackoffMs { get; set; }

RequestTimeoutMs

Request timeout in ms (default: 30000).

public int RequestTimeoutMs { get; set; }

Retries

Default number of retries for failed sends.

public int Retries { get; set; }

SaslMechanism

SASL mechanism: Plain, ScramSha256, ScramSha512, OAuthBearer.

public string? SaslMechanism { get; set; }

SaslPassword

SASL password.

public string? SaslPassword { get; set; }

SaslUsername

SASL username.

public string? SaslUsername { get; set; }

SecurityProtocol

Security protocol: Plaintext, Ssl, SaslPlaintext, SaslSsl.

public string SecurityProtocol { get; set; }

SessionTimeoutMs

Consumer session timeout in ms (default: 45000). Lower = faster dead-consumer detection.

public int? SessionTimeoutMs { get; set; }

SocketTimeoutMs

Socket timeout in ms (default: 60000).

public int SocketTimeoutMs { get; set; }

SslCaLocation

CA certificate file path for SSL.

public string? SslCaLocation { get; set; }

SslCertificateLocation

Client certificate file path (for mTLS).

public string? SslCertificateLocation { get; set; }

SslEndpointIdentificationAlgorithm

SSL endpoint identification: "https" verifies the broker hostname against its certificate, "none" (or empty)

public string? SslEndpointIdentificationAlgorithm { get; set; }

SslKeyLocation

Client private key file path (for mTLS).

public string? SslKeyLocation { get; set; }

SslKeyPassword

Client private key passphrase.

public string? SslKeyPassword { get; set; }

Methods

BuildAdminConfig()

Builds an for metadata queries.

public AdminClientConfig BuildAdminConfig()

BuildConsumerConfig(string?)

Builds a with all factory settings.

public ConsumerConfig BuildConsumerConfig(string? groupIdOverride = null)

BuildProducerConfig()

Builds a with all factory settings.

public ProducerConfig BuildProducerConfig()