Class KafkaConnectionFactory
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
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; }
Brokers
Comma-separated list of Kafka broker addresses (e.g., "broker1:9092,broker2:9092").
public string Brokers { get; set; }
CompressionType
Compression type: None, Gzip, Snappy, Lz4, Zstd.
public string? CompressionType { 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; }
SaslMechanism
SASL mechanism: Plain, ScramSha256, ScramSha512, OAuthBearer.
public string? SaslMechanism { 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; }
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; }
Methods
BuildConsumerConfig(string?)
Builds a with all factory settings.
public ConsumerConfig BuildConsumerConfig(string? groupIdOverride = null)