KafkaStorm 10.0.0
dotnet add package KafkaStorm --version 10.0.0
NuGet\Install-Package KafkaStorm -Version 10.0.0
<PackageReference Include="KafkaStorm" Version="10.0.0" />
<PackageVersion Include="KafkaStorm" Version="10.0.0" />
<PackageReference Include="KafkaStorm" />
paket add KafkaStorm --version 10.0.0
#r "nuget: KafkaStorm, 10.0.0"
#:package KafkaStorm@10.0.0
#addin nuget:?package=KafkaStorm&version=10.0.0
#tool nuget:?package=KafkaStorm&version=10.0.0
KafkaStorm
Simple .NET client for Kafka based on Confluent.Kafka.
Table of contents
- Requirements
- Features
- Installation
- Setup
- Assembly scanning
- Consuming
- Producing
- Examples
- Development
- Migrating from 9.x
- Related
Requirements
- .NET 10 SDK (LTS)
Features
- In-memory queue for messages that couldn't be sent
- Concurrent consumers via hosted services
- Producing messages concurrently
- JSON serialization via
System.Text.Json(no Schema Registry required)
Installation
Package Manager
Install-Package KafkaStorm -Version 10.0.0
.NET CLI
dotnet add package KafkaStorm --version 10.0.0
Setup
using Confluent.Kafka;
using KafkaStorm.Extensions;
using KafkaStorm.Interfaces;
builder.Services.AddKafkaStorm(factory =>
{
factory.AddProducer(prf =>
{
prf.ConfigProducer(new ProducerConfig
{
BootstrapServers = host
});
prf.InMemoryQueue();
prf.SetQueueLimit(65536);
});
// Start the background worker that drains the retry queue:
factory.StartProducerHostedService();
factory.AddConsumers(crf =>
{
crf.AddConsumer<HelloConsumer, HelloEvent>(new ConsumerConfig
{
BootstrapServers = "localhost:29092",
GroupId = "TestGroup"
}, "topicName");
});
});
Uses the same
ConsumerConfigandProducerConfigtypes as Confluent.Kafka.
Assembly scanning
Register all IConsumer<T> / IMessage pairs from an assembly:
using System.Reflection;
using Confluent.Kafka;
using KafkaStorm.Extensions;
using KafkaStorm.Interfaces;
builder.Services.AddKafkaStorm(factory =>
{
factory.AddConsumers(crf =>
{
var config = new ConsumerConfig
{
BootstrapServers = "localhost:29092",
GroupId = "TestGroup"
};
crf.AddConsumersFromAssembly(Assembly.GetExecutingAssembly(), config);
});
});
Message types used with assembly scanning must implement IMessage.
Consuming
using KafkaStorm.Interfaces;
using Microsoft.Extensions.Logging;
public class HelloConsumer(ILogger<HelloConsumer> logger) : IConsumer<HelloEvent>
{
public async Task Handle(HelloEvent @event, CancellationToken cancellationToken)
{
logger.LogDebug("Message received");
await Task.CompletedTask;
}
}
Event (message)
public class HelloEvent(DateTime time)
{
public string Message { get; } = "Hello";
public DateTime Time { get; } = time;
}
Note: Properties typed as interfaces may cause JSON deserialization errors.
Producing
Inject IProducer:
using KafkaStorm.Interfaces;
public class TestService(IProducer producer)
{
// Queue on failure (when in-memory queue is enabled):
public Task QueueProduce() => producer.Produce(new HelloEvent(DateTime.Now), "topicName");
// Send immediately:
public Task SendNow() => producer.ProduceNowAsync(new HelloEvent(DateTime.Now), "topicName");
}
Examples
See samples/BasicWebApi for a minimal Web API that produces and consumes Kafka messages with KafkaStorm.
Development
git clone https://github.com/stormaref/KafkaStorm.git
cd KafkaStorm
dotnet restore
dotnet build -c Release
dotnet test -c Release
See CONTRIBUTING.md for contribution guidelines.
Migrating from 9.x
- Target .NET 10 and use package version 10.0.0.
- Public registration APIs (
AddKafkaStorm,AddProducer,AddConsumer, etc.) are unchanged. - Breaking: Direct use of static fields on
ProducerRegistrationFactoryorConsumerRegistrationFactoryis no longer supported. Use normal DI registration instead.
See CHANGELOG.md for full release notes.
Author
Related
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Confluent.Kafka (>= 2.14.0)
- Microsoft.Extensions.DependencyInjection (>= 10.0.0)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated | |
|---|---|---|---|
| 10.0.0 | 96 | 6/4/2026 | |
| 9.0.0 | 304 | 1/2/2025 | |
| 8.1.0 | 329 | 4/20/2024 | |
| 8.0.6 | 297 | 4/17/2024 | |
| 8.0.5 | 311 | 4/17/2024 | |
| 8.0.4 | 289 | 4/17/2024 | |
| 8.0.3 | 277 | 4/17/2024 | |
| 8.0.2 | 392 | 2/28/2024 | |
| 8.0.1 | 334 | 2/28/2024 | |
| 8.0.0 | 321 | 2/28/2024 | |
| 1.9.0 | 591 | 5/6/2023 | |
| 1.8.1 | 620 | 5/6/2023 | |
| 1.8.0 | 757 | 12/22/2022 | |
| 1.7.0 | 997 | 1/19/2022 | |
| 1.5.0 | 914 | 1/19/2022 | |
| 1.4.0 | 905 | 1/19/2022 | |
| 1.3.0 | 911 | 1/18/2022 | |
| 1.2.3 | 925 | 1/18/2022 | |
| 1.2.2 | 925 | 1/18/2022 | |
| 1.2.1 | 890 | 1/18/2022 |