Franz.Common.Messaging.Hosting.Kafka
2.2.16
dotnet add package Franz.Common.Messaging.Hosting.Kafka --version 2.2.16
NuGet\Install-Package Franz.Common.Messaging.Hosting.Kafka -Version 2.2.16
<PackageReference Include="Franz.Common.Messaging.Hosting.Kafka" Version="2.2.16" />
<PackageVersion Include="Franz.Common.Messaging.Hosting.Kafka" Version="2.2.16" />Directory.Packages.props
<PackageReference Include="Franz.Common.Messaging.Hosting.Kafka" />Project file
paket add Franz.Common.Messaging.Hosting.Kafka --version 2.2.16
#r "nuget: Franz.Common.Messaging.Hosting.Kafka, 2.2.16"
#:package Franz.Common.Messaging.Hosting.Kafka@2.2.16
#addin nuget:?package=Franz.Common.Messaging.Hosting.Kafka&version=2.2.16Install as a Cake Addin
#tool nuget:?package=Franz.Common.Messaging.Hosting.Kafka&version=2.2.16Install as a Cake Tool
Franz.Common.Messaging.Hosting.Kafka
A Kafka hosting integration for the Franz Framework that connects the Kafka
transport layer (Franz.Common.Messaging.Kafka) to the .NET hosting runtime
(Microsoft.Extensions.Hosting).
This package is responsible only for:
- background execution
- hosted listeners
- message dispatch orchestration
π§± Kafka transport, producers, consumers, and configuration live in
Franz.Common.Messaging.Kafka
β¨ Features
Hosted Services
KafkaHostedService
Runs a Kafka listener inside a .NETBackgroundService.MessagingHostedService
Orchestrates message dispatch:- creates scoped execution contexts
- resolves messaging strategies
- dispatches messages safely
OutboxHostedService
Publishes messages stored in an outbox (SQL / Mongo) to Kafka reliably.
Dependency Injection Extensions
KafkaHostingServiceCollectionExtensions- Simple registration via:
AddKafkaHostedListener()AddOutboxHostedListener()
Separation of Concerns
- No Kafka configuration here
- No Kafka consumer creation here
- Hosting depends on abstractions only
Observability
- Structured logging
- Emoji-based lifecycle signals
- Compatible with OpenTelemetry
- Correlation via
MessageContextAccessor
π Project Structure
Franz.Common.Messaging.Hosting.Kafka/
βββ Extensions/
β βββ KafkaHostingServiceCollectionExtensions.cs
βββ HostedServices/
β βββ KafkaHostedService.cs
β βββ MessagingHostedService.cs
β βββ OutboxHostedService.cs
βββ README.md
βοΈ Dependencies
- Microsoft.Extensions.Hosting (10.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (10.0.0)
- Franz.Common.Messaging
- Franz.Common.Messaging.Kafka
- Franz.Common.Messaging.Hosting
β οΈ This package assumes Kafka transport is already registered via
Franz.Common.Messaging.Kafka.
π Usage
1οΈβ£ Register Kafka Transport (required)
using Franz.Common.Messaging.Kafka.Extensions;
services.AddKafkaMessaging(configuration);
2οΈβ£ Register Kafka Hosted Services
using Franz.Common.Messaging.Hosting.Kafka.Extensions;
services.AddKafkaHostedListener(configuration);
services.AddOutboxHostedListener(configuration);
This will:
- start background Kafka consumption
- dispatch messages through Franz messaging strategies
- process outbox messages reliably
π Kafka Hosted Service Lifecycle
public sealed class KafkaHostedService : BackgroundService
{
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
// Subscribes to Kafka topics
// Listens until host shutdown
// Dispatches messages safely
}
}
Behavior:
- graceful shutdown
- no host crashes on bad messages
- scope-per-message execution
π¦ Outbox Hosted Service
public sealed class OutboxHostedService : BackgroundService
{
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
// Reads outbox
// Publishes to Kafka
// Handles retries & DLQ
}
}
Guarantees:
- at-least-once delivery
- retry control
- no message loss on crashes
π Observability
Emoji logging conventions:
- π startup
- π shutdown
- β οΈ recoverable failure
- β execution error
- π₯ DLQ
Correlation IDs via
MessageContextAccessorOpenTelemetry-compatible spans
π§ Architectural Role
| Concern | Package |
|---|---|
| Kafka transport | Franz.Common.Messaging.Kafka |
| Kafka consumer creation | Franz.Common.Messaging.Kafka |
| Hosted execution | Franz.Common.Messaging.Hosting.Kafka |
| Dispatch orchestration | Franz.Common.Messaging.Hosting.Kafka |
This ensures:
- clean Testcontainers integration
- deterministic CI behavior
- no hidden threads
- safe message handling
π§Ύ Version Information
- Current Version: v2.2.16
- Target Framework: .NET 10.0
- Part of the Franz Framework
π Changelog
v2.0.1 β Internal Modernization
- Messaging and infrastructure refactored for async, thread-safety, and modern .NET 10 patterns.
- All APIs remain fully backward compatible.
- Tests, listeners, and pipeline components modernized.
Version 1.7.01
- π§± Enforced strict separation between Kafka transport and hosting
- π Removed Kafka consumer creation from hosting layer
- π Hosting now depends exclusively on
IListener - β»οΈ Fixed lifecycle handling and graceful shutdown
- π§ͺ Improved Testcontainers and CI reliability
- β¬οΈ Upgraded to .NET 10.0
Version 1.6.20
- Initial Kafka hosting support
- Added
KafkaHostedService - Added
OutboxHostedService - Introduced hosting DI extensions
- Integrated
MessageContextAccessor - Emoji-based logging conventions
π License
MIT License
See the LICENSE file for details.
| 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
- Franz.Common.Messaging.Hosting (>= 2.2.16)
- Franz.Common.Messaging.Kafka (>= 2.2.16)
- SharpCompress (>= 1.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Franz.Common.Messaging.Hosting.Kafka:
| Package | Downloads |
|---|---|
|
Franz.Common.Http.Messaging
Shared utility library for the Franz Framework. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.2.16 | 50 | 7/2/2026 |
| 2.2.15 | 101 | 6/29/2026 |
| 2.2.14 | 99 | 6/29/2026 |
| 2.2.13 | 103 | 6/29/2026 |
| 2.2.12 | 104 | 6/28/2026 |
| 2.2.11 | 111 | 6/28/2026 |
| 2.2.10 | 103 | 6/28/2026 |
| 2.2.9 | 109 | 6/28/2026 |
| 2.2.8 | 100 | 6/28/2026 |
| 2.2.7 | 116 | 6/7/2026 |
| 2.2.6 | 113 | 6/6/2026 |
| 2.2.5 | 116 | 6/4/2026 |
| 2.2.4 | 113 | 6/3/2026 |
| 2.2.3 | 97 | 6/2/2026 |
| 2.2.2 | 107 | 6/2/2026 |
| 2.2.1 | 103 | 5/24/2026 |
| 2.1.4 | 108 | 4/27/2026 |
| 2.1.3 | 101 | 4/26/2026 |
| 2.1.2 | 105 | 4/26/2026 |
| 2.1.1 | 114 | 4/22/2026 |