Skip to content

Kafka Client Options (v3)

Compare
Choose a tag to compare
@kmcclellan kmcclellan released this 28 Mar 11:56
· 3 commits to main since this release

Version three of this library replaces a number of components with KafkaClientOptions. It leverages the options pattern instead working directly with IServiceCollection. It also introduces default binding of librdkafka string config properties to IConfiguration. See README/example for usage.

Upgrade guide:

The namespace for the AddKafkaClient extension has changed from Confluent.Kafka.DependencyInjection to Confluent.Kafka.

Instances of ProducerConfig, ConsumerConfig, or AdminClientConfig that were passed to v2 AddKafkaClient(config) should instead be passed via the options builder:

services.AddKafkaClient().Configure(opts => opts.Configure(config));

Raw config properties in the form of string key/value pairs should be bound to the Kafka configuration section, using a config provider such as JSON or in-memory.

Serialization types registered with the container are no longer automatically picked up by injected clients and will need passed via the options builder:

services.AddKafkaClient().Configure<ISerializer<string, string>>((opts, serializer) => opts.Serialize(serializer));

Implementations of event handler types will also need passed to the builder using delegates (KafkaClientOptions.OnError(...) etc.).

"Typed clients" are no longer supported. If you need your application to support different configurations, I suggest exploring named options with IOptionsFactory<KafkaClientOptions>.