VOOZH about

URL: https://www.nuget.org/packages/Franz.Common.Messaging.Hosting.Kafka/

โ‡ฑ NuGet Gallery | Franz.Common.Messaging.Hosting.Kafka 2.2.7


๏ปฟ

Franz.Common.Messaging.Hosting.Kafka 2.2.7

dotnet add package Franz.Common.Messaging.Hosting.Kafka --version 2.2.7
 
 
NuGet\Install-Package Franz.Common.Messaging.Hosting.Kafka -Version 2.2.7
 
 
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="Franz.Common.Messaging.Hosting.Kafka" Version="2.2.7" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Franz.Common.Messaging.Hosting.Kafka" Version="2.2.7" />
 
Directory.Packages.props
<PackageReference Include="Franz.Common.Messaging.Hosting.Kafka" />
 
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 Franz.Common.Messaging.Hosting.Kafka --version 2.2.7
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Franz.Common.Messaging.Hosting.Kafka, 2.2.7"
 
 
#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 Franz.Common.Messaging.Hosting.Kafka@2.2.7
 
 
#: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=Franz.Common.Messaging.Hosting.Kafka&version=2.2.7
 
Install as a Cake Addin
#tool nuget:?package=Franz.Common.Messaging.Hosting.Kafka&version=2.2.7
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

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 .NET BackgroundService.

  • 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 MessageContextAccessor

  • OpenTelemetry-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.7
  • 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 net10.0 is compatible.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows 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 (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.7 110 6/7/2026
2.2.6 108 6/6/2026
2.2.5 111 6/4/2026
2.2.4 109 6/3/2026
2.2.3 92 6/2/2026
2.2.2 101 6/2/2026
2.2.1 98 5/24/2026
2.1.4 106 4/27/2026
2.1.3 100 4/26/2026
2.1.2 102 4/26/2026
2.1.1 111 4/22/2026
2.0.2 115 3/30/2026
2.0.1 111 3/29/2026
1.7.8 114 3/2/2026
1.7.7 126 1/31/2026
1.7.6 127 1/22/2026
1.7.5 172 1/10/2026
1.7.4 120 12/27/2025
1.7.3 201 12/22/2025
1.7.2 199 12/21/2025
Loading failed