KafkaStorm 10.0.0

dotnet add package KafkaStorm --version 10.0.0
                    
NuGet\Install-Package KafkaStorm -Version 10.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="KafkaStorm" Version="10.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="KafkaStorm" Version="10.0.0" />
                    
Directory.Packages.props
<PackageReference Include="KafkaStorm" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add KafkaStorm --version 10.0.0
                    
#r "nuget: KafkaStorm, 10.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package KafkaStorm@10.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=KafkaStorm&version=10.0.0
                    
Install as a Cake Addin
#tool nuget:?package=KafkaStorm&version=10.0.0
                    
Install as a Cake Tool

KafkaStorm

NuGet CI License .NET

Simple .NET client for Kafka based on Confluent.Kafka.

Table of contents

Requirements

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 ConsumerConfig and ProducerConfig types 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 ProducerRegistrationFactory or ConsumerRegistrationFactory is no longer supported. Use normal DI registration instead.

See CHANGELOG.md for full release notes.

Author

@stormaref

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.5 is deprecated because it has critical bugs.
8.0.4 289 4/17/2024
8.0.3 277 4/17/2024
8.0.2 392 2/28/2024 8.0.2 is deprecated because it has critical bugs.
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
Loading failed