Itmo.Dev.Platform.Kafka 1.0.65

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Itmo.Dev.Platform.Kafka --version 1.0.65                
NuGet\Install-Package Itmo.Dev.Platform.Kafka -Version 1.0.65                
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="Itmo.Dev.Platform.Kafka" Version="1.0.65" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Itmo.Dev.Platform.Kafka --version 1.0.65                
#r "nuget: Itmo.Dev.Platform.Kafka, 1.0.65"                
#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.
// Install Itmo.Dev.Platform.Kafka as a Cake Addin
#addin nuget:?package=Itmo.Dev.Platform.Kafka&version=1.0.65

// Install Itmo.Dev.Platform.Kafka as a Cake Tool
#tool nuget:?package=Itmo.Dev.Platform.Kafka&version=1.0.65                

Itmo.Dev.Platform.Kafka

Platform extensions for working with Kafka

Consumer

Implement message handler

public class MyMessageHandler : IKafkaMessageHandler<int, string>
{
    public ValueTask HandleAsync(
        IEnumerable<ConsumerKafkaMessage<TKey, TValue>> messages, 
        CancellationToken cancellationToken)
    {
        foreach (var message in messages)
        {
            Console.WriteLine($"Received message, Key = {message.Key}, Value = {message.Value}");
        }
        
        return ValueTask.CompletedTask;
    }
}

Implement configuration type

public class Configuration : IKafkaConsumerConfiguration
{
    public bool IsDisabled { get; init; }

    public TimeSpan DisabledConsumerTimeout { get; init; }

    public string Host { get; set; } = string.Empty;

    public string Topic { get; init; } = string.Empty;

    public string Group { get; init; } = string.Empty;

    public int ParallelismDegree { get; init; }

    public int BufferSize { get; init; }

    public TimeSpan BufferWaitLimit { get; init; }

    public bool ReadLatest { get; init; }
}

At runtime, configuration would be received as IOptionsMonitor<TConfiguration>, so you should manually register it to DI container as options.

Add consumer to your ASP.NET server services

Consumer requires an ASP.NET host, as it is implemented as hosted service

Use extension methods to register your consumer.

collection.AddKafkaConsumer<int, string>(builder => builder
    .HandleWith<MyMessageHandler>()
    .DeserializeKeyWithNewtonsoft()
    .DeserializeValueWithNewtonsoft()
    .UseConfiguration<Configuration>());

If you want to use custom deserializer, you can call DeserializeKeyWith<T> where T : IDeserializer<T> method, same way with value deserialization.

If your topic model is defined as protobuf, you can call DeserializeKeyWithProto extension method, same way with value deserialization.

Producer

Add producer to your service collection

collection.AddKafkaProducer<int, string>(builder => builder
    .SerializeKeyWithNewtonsoft()
    .SerializeValueWithNewtonsoft()
    .UseConfiguration<Configuration>());

You can use protobuf serialization same way as it is with consumer.

Resolve producer instance from service provider

var producer = provider.GetRequiredService<IKafkaMessageProducer<int, string>>();
await producer.ProduceAsync(messages, default);
Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  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 was computed.  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. 
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
2.3.247 85 12/24/2024
2.3.237 147 11/30/2024
2.2.234 144 11/18/2024
2.2.232 86 11/18/2024
2.2.228 82 10/31/2024
2.2.206 123 10/30/2024
2.2.204 106 10/29/2024
2.2.202 79 10/29/2024
2.1.196 78 10/29/2024
2.1.193 83 10/29/2024
2.1.190 92 10/26/2024
2.0.174 84 10/25/2024
2.0.133 80 10/25/2024
2.0.132 79 10/24/2024
2.0.131 110 10/24/2024
2.0.130 81 10/24/2024
2.0.129 84 10/24/2024
2.0.128 89 10/24/2024
2.0.127 86 10/23/2024
2.0.126 89 10/11/2024
2.0.125 87 10/11/2024
2.0.124 82 10/11/2024
2.0.123 80 10/11/2024
2.0.122 88 10/11/2024
2.0.121 86 10/11/2024
2.0.120 92 10/11/2024
2.0.119 87 10/11/2024
2.0.118 96 10/11/2024
2.0.117 88 10/10/2024
2.0.115 90 10/10/2024
2.0.113 84 10/6/2024
2.0.112 138 8/22/2024
2.0.111 149 5/14/2024
2.0.110 118 5/13/2024
2.0.109 113 5/13/2024
2.0.108 136 5/6/2024
2.0.107 117 5/6/2024
2.0.106 116 5/6/2024
2.0.105 116 5/4/2024
2.0.102 127 5/4/2024
2.0.101 114 4/26/2024
2.0.100 130 4/22/2024
2.0.99 113 4/21/2024
2.0.98 116 4/21/2024
2.0.97 108 4/19/2024
2.0.96 111 4/18/2024
2.0.95 108 4/18/2024
2.0.94 134 2/13/2024
2.0.93 131 2/10/2024
2.0.91 108 2/10/2024
2.0.90 123 2/10/2024
2.0.89 262 2/3/2024
2.0.86 109 2/1/2024
1.1.85 115 1/30/2024
1.1.83 158 1/27/2024
1.1.82 198 1/5/2024
1.1.81 286 1/3/2024
1.0.80 148 12/30/2023
1.0.79 128 12/30/2023
1.0.78 131 12/30/2023
1.0.77 141 12/28/2023
1.0.76 128 12/27/2023
1.0.75 166 12/9/2023
1.0.73 166 11/30/2023
1.0.72 146 11/27/2023
1.0.71 145 11/27/2023
1.0.70 134 11/27/2023
1.0.69 116 11/27/2023
1.0.67 148 11/25/2023
1.0.66 135 11/25/2023
1.0.65 141 11/23/2023
1.0.64 129 11/23/2023
1.0.62 133 11/18/2023
1.0.61 137 11/18/2023
1.0.60 126 11/17/2023
1.0.59 128 11/16/2023
1.0.58 122 11/13/2023
1.0.57 113 11/12/2023
1.0.56 126 11/12/2023
1.0.54 131 11/7/2023
1.0.53 131 11/4/2023
1.0.52 158 10/29/2023
1.0.51 141 10/29/2023
1.0.50 149 10/29/2023
1.0.48 133 10/29/2023

Added options post configure