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
                    
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="1.6.19" />
                    
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="1.6.19" />
                    
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 1.6.19
                    
#r "nuget: Franz.Common.Messaging.Hosting.Kafka, 1.6.19"
                    
#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@1.6.19
                    
#: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=1.6.19
                    
Install as a Cake Addin
#tool nuget:?package=Franz.Common.Messaging.Hosting.Kafka&version=1.6.19
                    
Install as a Cake Tool

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

    • KafkaHostingServiceCollectionExtensions simplifies service registration in Startup/Program.cs.
    • Provides one-liners like AddKafkaHostedListener() and AddOutboxHostedListener().
  • Separation of Concerns

    • Keeps transport logic (Franz.Common.Messaging.Kafka) separate from hosting concerns.
    • Makes testing listeners independent of the hosting runtime.
  • 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 MessageContextAccessor for 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 KafkaHostedService to run Kafka listeners inside .NET host.
  • Added OutboxHostedService to bridge Mongo outbox with Kafka publishing.
  • Added KafkaHostingServiceCollectionExtensions for simple DI registration.
  • Unified hosted services with MessageContextAccessor and inbox idempotency support.
  • Improved logging with emoji conventions and OpenTelemetry hooks.
Product 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. 
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
1.6.19 27 10/25/2025
1.6.15 149 10/20/2025
1.6.14 157 10/15/2025
1.6.3 162 10/9/2025
1.6.2 166 10/7/2025