LinKit.Messaging.Kafka
1.0.0
dotnet add package LinKit.Messaging.Kafka --version 1.0.0
NuGet\Install-Package LinKit.Messaging.Kafka -Version 1.0.0
<PackageReference Include="LinKit.Messaging.Kafka" Version="1.0.0" />
<PackageVersion Include="LinKit.Messaging.Kafka" Version="1.0.0" />
<PackageReference Include="LinKit.Messaging.Kafka" />
paket add LinKit.Messaging.Kafka --version 1.0.0
#r "nuget: LinKit.Messaging.Kafka, 1.0.0"
#:package LinKit.Messaging.Kafka@1.0.0
#addin nuget:?package=LinKit.Messaging.Kafka&version=1.0.0
#tool nuget:?package=LinKit.Messaging.Kafka&version=1.0.0
LinKit.Messaging.Kafka
This package provides the Apache Kafka implementation for the abstractions defined in the LinKit.Core
Messaging Kit. It allows the LinKit source generator to create publishers and consumers that communicate with a Kafka cluster.
Prerequisites
- You must have
LinKit.Core
installed. - You need access to a running Kafka cluster.
- This package depends on the native
librdkafka
library viaConfluent.Kafka
. Ensure it is compatible with your target deployment environment, especially for AOT scenarios.
For a complete guide on how to define messages with [Message]
and create handlers with [CqrsHandler]
, please refer to the main LinKit documentation.
Installation
dotnet add package LinKit.Messaging.Kafka
How to Use
1. Configure appsettings.json
Add a configuration section for your Kafka connection. The default section name is "Kafka"
.
{
"Kafka": {
"BootstrapServers": "localhost:9092",
"GroupId": "my-application-consumer-group"
}
}
The GroupId
is essential for your consumers.
2. Register Services in Program.cs
In your application's startup code (e.g., Program.cs
for a Worker Service), use the AddLinKitKafka()
extension method after registering the core LinKit services.
using LinKit.Core;
using LinKit.Messaging.Kafka;
var builder = Host.CreateApplicationBuilder(args);
// 1. Register core LinKit services.
// This generates the IMessagePublisher and your consumer IHostedService(s).
builder.Services.AddLinKitCqrs();
builder.Services.AddLinKitMessaging();
// 2. Provide the Kafka implementation.
// This "plugs in" Kafka to the generated services.
builder.Services.AddLinKitKafka(builder.Configuration);
var host = builder.Build();
host.Run();
That's it! Your application is now configured to publish and consume messages via Kafka. The AddLinKitKafka
method registers the necessary IBrokerProducer
and IBrokerConnection
implementations, allowing your auto-generated services to connect to Kafka seamlessly.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. 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. |
-
net8.0
- Confluent.Kafka (>= 2.3.0)
- LinKit.Core (>= 1.0.5)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 8.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 |
---|---|---|
1.0.0 | 194 | 8/29/2025 |