Epam.Kafka
2.2.84
Prefix Reserved
See the version list below for details.
dotnet add package Epam.Kafka --version 2.2.84
NuGet\Install-Package Epam.Kafka -Version 2.2.84
<PackageReference Include="Epam.Kafka" Version="2.2.84" />
paket add Epam.Kafka --version 2.2.84
#r "nuget: Epam.Kafka, 2.2.84"
// Install Epam.Kafka as a Cake Addin #addin nuget:?package=Epam.Kafka&version=2.2.84 // Install Epam.Kafka as a Cake Tool #tool nuget:?package=Epam.Kafka&version=2.2.84
Epam.Kafka
About
Epam.Kafka package provides AddKafka
extension methods for IServiceCollection
, IKafkaFactory
interface and its default implementation. This provides the ability to set up named ConsumerConfig
, IConsumer<TKey, TValue>
, ProducerConfig
, IProducer<TKey, TValue>
, IClient
, ISchemaRegistryClient
configurations in a DI container and later retrieve them via an injected IKafkaFactory
instance.
Key Features
- Fluently set up multiple
ConsumerConfig
,IConsumer<TKey, TValue>
,ProducerConfig
,IProducer<TKey, TValue>
,IClient
,ISchemaRegistryClient
configurations for applications that use DI viaAddKafka
extension method. KafkaFactory
cachesIClient
,ISchemaRegistryClient
instances per configuration name, which allows to reuse resources.
How to Use
Configuring IKafkaFactory using fluent API
KafkaBuilder kafkaBuilder = services.AddKafka();
kafkaBuilder.WithClusterConfig("Sandbox").Configure(options =>
{
options.ClientConfig.BootstrapServers = "localhost:9092";
options.ClientConfig.AllowAutoCreateTopics = true;
options.SchemaRegistryConfig.Url = "localhost:8081";
});
kafkaBuilder.WithConsumerConfig("Default").Configure(options =>
{
options.ConsumerConfig.GroupId = "consumer.epam-kafka-sample";
});
Using the configured IKafkaFactory
public class ConsumerSample : BackgroundService
{
private readonly IKafkaFactory _kafkaFactory;
public ConsumerSample(IKafkaFactory kafkaFactory)
{
this._kafkaFactory = kafkaFactory ?? throw new ArgumentNullException(nameof(kafkaFactory));
}
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
ConsumerConfig config = this._kafkaFactory.CreateConsumerConfig("Default");
using IConsumer<string, string> consumer = this._kafkaFactory.CreateConsumer<string, string>(config, "Sandbox");
consumer.Subscribe("epam-kafka-sample-topic-123");
while (!stoppingToken.IsCancellationRequested)
{
ConsumeResult<string, string>? result = consumer.Consume(stoppingToken);
Console.WriteLine($"Consumed {result.TopicPartitionOffset}");
}
}
}
Configuring IKafkaFactory using IConfiguration
By default IKafkaFactory
configured from IConfiguration
registered in IServiceCollection
. This configuration can be extended or modified using fluent API. Sample of json config:
{
"Kafka": {
"Default": {
"Cluster": "Sandbox",
"Consumer": "Default",
"Producer": "Default"
},
"Clusters": {
"Sandbox": {
"bootstrap.servers": "localhost:9092",
"allow.auto.create.topics": true,
"schema.registry.url": "localhost:8081"
}
},
"Producers": {
"Default": {
"client.id": "<DomainName>@<MachineName>"
},
"Transactional": {
"client.id": "<DomainName>@<MachineName>"
"transactional.id": "producer.epam-kafka-sample"
}
},
"Consumers": {
"Default": {
"group.id": "consumer.epam-kafka-sample"
}
}
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.6.2
- Confluent.Kafka (>= 2.4.0)
- Confluent.SchemaRegistry (>= 2.4.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 6.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 6.0.0)
- Microsoft.Extensions.Options (>= 6.0.0)
-
.NETStandard 2.0
- Confluent.Kafka (>= 2.4.0)
- Confluent.SchemaRegistry (>= 2.4.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 6.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 6.0.0)
- Microsoft.Extensions.Options (>= 6.0.0)
-
net6.0
- Confluent.Kafka (>= 2.4.0)
- Confluent.SchemaRegistry (>= 2.4.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 6.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 6.0.0)
- Microsoft.Extensions.Options (>= 6.0.0)
-
net8.0
- Confluent.Kafka (>= 2.4.0)
- Confluent.SchemaRegistry (>= 2.4.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Options (>= 8.0.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Epam.Kafka:
Package | Downloads |
---|---|
Epam.Kafka.PubSub
Framework for building pub/sub batch processing applications |
|
Epam.Kafka.HealthChecks
Health check extensions for [Epam.Kafka](https://www.nuget.org/packages/Epam.Kafka) package. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2.3.146-rc | 174 | 10/1/2024 |
2.3.145 | 647 | 10/1/2024 |
2.3.143-rc | 169 | 9/25/2024 |
2.3.140 | 1,941 | 7/15/2024 |
2.3.138-rc | 156 | 7/15/2024 |
2.3.136-rc | 165 | 7/15/2024 |
2.3.129-rc | 181 | 7/11/2024 |
2.3.127-rc | 211 | 7/10/2024 |
2.3.119-rc | 185 | 7/9/2024 |
2.3.117-rc | 221 | 7/9/2024 |
2.3.114-rc | 205 | 7/8/2024 |
2.3.113-rc | 201 | 7/8/2024 |
2.3.109-rc | 188 | 7/8/2024 |
2.3.108-rc | 205 | 7/5/2024 |
2.3.104-rc | 208 | 6/28/2024 |
2.3.98-rc | 210 | 6/27/2024 |
2.3.96-rc | 201 | 6/26/2024 |
2.3.94-rc | 219 | 6/26/2024 |
2.3.92-rc | 194 | 6/25/2024 |
2.3.87-rc | 158 | 6/19/2024 |
2.3.85-rc | 173 | 6/19/2024 |
2.2.84 | 263 | 6/19/2024 |
2.2.80-rc | 213 | 6/17/2024 |
2.2.78-rc | 191 | 6/14/2024 |
2.2.61-rc | 157 | 6/11/2024 |
2.1.55 | 273 | 6/7/2024 |
2.1.52-rc | 168 | 6/7/2024 |
2.1.51-rc | 157 | 6/7/2024 |
2.1.49-rc | 166 | 6/6/2024 |
2.1.47-rc | 154 | 6/4/2024 |
2.1.45-rc | 183 | 6/4/2024 |
2.1.41-rc | 221 | 5/29/2024 |
2.1.38-rc | 178 | 5/29/2024 |
2.0.36 | 286 | 4/8/2024 |
2.0.34-rc | 161 | 4/8/2024 |
2.0.32-rc | 150 | 4/5/2024 |
2.0.31-rc | 90 | 4/5/2024 |
2.0.0-rc | 143 | 4/5/2024 |
API to support custom placeholders for 'Kafka:Consumers', 'Kafka:Producers', and 'Kafka:Clusters' configuration sections when kafka builder added with 'useConfiguration = true' parameter.
New extension methods to get and set 'dotnet.cancellation.delay.max.ms' value for ConsumerConfig.
New extension method to clone Kafka Config and optionally resolve placeholders.