Franz.Common.Messaging.Hosting.Kafka
1.6.19
dotnet add package Franz.Common.Messaging.Hosting.Kafka --version 1.6.19
NuGet\Install-Package Franz.Common.Messaging.Hosting.Kafka -Version 1.6.19
<PackageReference Include="Franz.Common.Messaging.Hosting.Kafka" Version="1.6.19" />
<PackageVersion Include="Franz.Common.Messaging.Hosting.Kafka" Version="1.6.19" />
<PackageReference Include="Franz.Common.Messaging.Hosting.Kafka" />
paket add Franz.Common.Messaging.Hosting.Kafka --version 1.6.19
#r "nuget: Franz.Common.Messaging.Hosting.Kafka, 1.6.19"
#:package Franz.Common.Messaging.Hosting.Kafka@1.6.19
#addin nuget:?package=Franz.Common.Messaging.Hosting.Kafka&version=1.6.19
#tool nuget:?package=Franz.Common.Messaging.Hosting.Kafka&version=1.6.19
Franz.Common.Messaging.Hosting.Kafka
A dedicated hosting library within the Franz Framework that provides Kafka-specific hosted services and dependency injection extensions.
This package bridges the Kafka transport layer (Franz.Common.Messaging.Kafka) with the .NET hosting infrastructure (Microsoft.Extensions.Hosting).
✨ Features
Hosted Services
KafkaHostedService– continuously consumes Kafka messages and dispatches them.OutboxHostedService– publishes stored outbox messages to Kafka in the background.MessagingHostedService– general-purpose hosted message orchestrator.
Dependency Injection Extensions
KafkaHostingServiceCollectionExtensionssimplifies service registration inStartup/Program.cs.- Provides one-liners like
AddKafkaHostedListener()andAddOutboxHostedListener().
Separation of Concerns
- Keeps transport logic (
Franz.Common.Messaging.Kafka) separate from hosting concerns. - Makes testing listeners independent of the hosting runtime.
- Keeps transport logic (
Observability
- Structured logging with emoji conventions (✅ success, ⚠️ retries, 🔥 DLQ).
- Compatible with OpenTelemetry for distributed tracing.
📂 Project Structure
Franz.Common.Messaging.Hosting.Kafka/
├── Extensions/
│ └── KafkaHostingServiceCollectionExtensions.cs
├── HostedServices/
│ ├── KafkaHostedService.cs
│ ├── MessagingHostedService.cs
│ └── OutboxHostedService.cs
└── readme.md
⚙️ Dependencies
- Microsoft.Extensions.Hosting (8.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (8.0.0)
- Franz.Common.Messaging – core messaging abstractions
- Franz.Common.Messaging.Kafka – Kafka transport adapter
- Franz.Common.Messaging.Hosting – base hosting abstractions
🚀 Usage
1. Register Kafka Hosted Services
In Program.cs or Startup.cs:
using Franz.Common.Messaging.Hosting.Kafka.Extensions;
var host = Host.CreateDefaultBuilder(args)
.ConfigureServices((context, services) =>
{
services.AddKafkaHostedListener(context.Configuration);
services.AddOutboxHostedListener(context.Configuration);
})
.Build();
await host.RunAsync();
2. Kafka Hosted Service
Runs in the background to consume Kafka messages and dispatch them via the mediator:
public class KafkaHostedService : BackgroundService
{
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
// Consumes Kafka messages and dispatches
}
}
3. Outbox Hosted Service
Ensures pending messages in MongoDB/SQL outbox are published to Kafka reliably:
public class OutboxHostedService : BackgroundService
{
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
// Reads outbox, sends to Kafka, handles retries/DLQ
}
}
📊 Observability
- Emoji logging (✅ processed, ⚠️ retry, 🔥 DLQ, 💤 idle).
- Integrated with
MessageContextAccessorfor correlation IDs. - Tracing compatible with OpenTelemetry.
📝 Version Information
- Current Version: 1.6.19
- Part of the private Franz Framework ecosystem.
📜 License
This library is licensed under the MIT License. See the LICENSE file for details.
📖 Changelog
Version 1.6.2
- Introduced
KafkaHostedServiceto run Kafka listeners inside .NET host. - Added
OutboxHostedServiceto bridge Mongo outbox with Kafka publishing. - Added
KafkaHostingServiceCollectionExtensionsfor simple DI registration. - Unified hosted services with
MessageContextAccessorand inbox idempotency support. - Improved logging with emoji conventions and OpenTelemetry hooks.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. 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. |
-
net9.0
- Franz.Common.Messaging.Hosting (>= 1.6.19)
- Franz.Common.Messaging.Kafka (>= 1.6.19)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.