-
Notifications
You must be signed in to change notification settings - Fork 0
Kafka client fine tuning
Artem Utkin edited this page May 28, 2023
·
1 revision
Kafka.EventLoop
is built on top of the Confluent's .NET Client for Apache Kafka.
You have access to its consumer and producer configurations through the helper method HasKafkaConfig
.
services.AddKafkaEventLoop(ctx.Configuration, o => o
.HasConsumerGroup("<your-consumer-group-id>", cgOptions => cgOptions
.HasMessageType<MyMessage>()
.HasJsonMessageDeserializer()
.HasController<MyController>()
.HasKafkaConfig(c => c.AutoOffsetReset = AutoOffsetReset.Earliest) // <--
.HasKafkaConfig(c => c.MaxPollIntervalMs = 900000) // <--
.Build())
.Build());
-
EnableAutoCommit - you cannot set
true
because the library makes manual commits after each successful message processing. -
EnableAutoOffsetStore - you cannot set
true
because the library disables auto-offset store as it's not needed with manual commits.
services.AddKafkaEventLoop(ctx.Configuration, o => o
.HasConsumerGroup("<your-consumer-group-id>", cgOptions => cgOptions
.HasMessageType<MyMessage>()
.HasJsonMessageDeserializer()
.HasController<MyController>()
.HasDeadLettering(dlOptions => dlOptions
.HasJsonDeadLetterMessageSerializer()
.HasKafkaConfig(p => p.Acks = Acks.All) // <-- example
.Build())
.Build())
.Build());
services.AddKafkaEventLoop(ctx.Configuration, o => o
.HasConsumerGroup("<your-consumer-group-id>", cgOptions => cgOptions
.HasMessageType<MyMessage>()
.HasJsonMessageDeserializer()
.HasController<MyController>()
.HasStreaming<MyExtendedMessage>(sOptions => sOptions
.HasJsonOutMessageSerializer()
.HasKafkaConfig(p => p.RequestTimeoutMs = 2000) // <-- example
.Build())
.Build())
.Build());