Franz.Common.Messaging.Kafka
2.3.1
dotnet add package Franz.Common.Messaging.Kafka --version 2.3.1
NuGet\Install-Package Franz.Common.Messaging.Kafka -Version 2.3.1
<PackageReference Include="Franz.Common.Messaging.Kafka" Version="2.3.1" />
<PackageVersion Include="Franz.Common.Messaging.Kafka" Version="2.3.1" />
<PackageReference Include="Franz.Common.Messaging.Kafka" />
paket add Franz.Common.Messaging.Kafka --version 2.3.1
#r "nuget: Franz.Common.Messaging.Kafka, 2.3.1"
#:package Franz.Common.Messaging.Kafka@2.3.1
#addin nuget:?package=Franz.Common.Messaging.Kafka&version=2.3.1
#tool nuget:?package=Franz.Common.Messaging.Kafka&version=2.3.1
Franz.Common.Messaging.Kafka
Messaging and distributed integration for the Franz.Common framework on .NET 10.
Overview
The Franz.Common.Messaging.Kafka package provides messaging and distributed integration within Franz.Common. It is designed to compose with the rest of the framework rather than imposing unrelated infrastructure choices on every application.
Installation
dotnet add package Franz.Common.Messaging.Kafka
Design principles
- Explicit composition: register only the capabilities the application needs.
- Clear boundaries: keep domain and application contracts independent from provider-specific infrastructure where the package's role permits it.
- Predictable behavior: make configuration, failure modes, and lifecycle ownership visible rather than relying on hidden conventions.
- Operational readiness: validate security, resilience, diagnostics, and compatibility for the actual deployment environment.
Usage and configuration
Follow the package-specific setup, configuration, and code examples below. Only configure external services when this package requires them, and keep secrets outside source control.
Package-specific guide
A Kafka transport integration for the Franz Framework, designed to provide clean, deterministic, and production-grade interaction with Kafka topics, producers, and consumers.
This package focuses exclusively on Kafka transport concerns: configuration, producers, consumers, serialization, and transactions.
๐งฑ Hosting, background execution, and listeners are intentionally not handled here. They live in Franz.Common.Messaging.Hosting.Kafka.
โจ Features
Kafka Transport & Configuration
- Centralized Kafka configuration via
MessagingOptions ConnectionProviderandConnectionFactoryProviderfor managing Kafka connections- Deterministic, DI-friendly Kafka setup
Kafka Producers
MessagingPublisherfor publishing integration eventsMessagingSenderfor point-to-point messaging- Automatic topic resolution and naming strategies
Kafka Consumers
- Native usage of
Confluent.Kafka.IConsumer<string, string> IKafkaConsumerFactoryas the single authority for consumer creation- Correct lifetime management aligned with Kafka consumer group semantics
Modeling
KafkaModelandModelProviderfor Kafka-based domain modeling- Strong separation between messaging models and business logic
Serialization
IMessageDeserializerJsonMessageDeserializer- Deterministic JSON serialization using Franz messaging contracts
Transactions
MessagingTransactionfor Kafka-backed transactional workflows
Utilities
ExchangeNamerandTopicNamerfor consistent topic naming- Messaging helpers shared across Franz transports
Dependency Injection
- Fluent
ServiceCollectionExtensionsfor Kafka transport registration - No accidental hosting or background execution side effects
๐งญ Architectural Scope
This package is transport-only.
| Responsibility | Package |
|---|---|
| Kafka producers | โ Franz.Common.Messaging.Kafka |
| Kafka consumers (transport) | โ Franz.Common.Messaging.Kafka |
| Background listeners | โ |
| Hosted services | โ |
| Message dispatch pipelines | โ |
| Hosting / workers | โ Franz.Common.Messaging.Hosting.Kafka |
This separation ensures:
- Testability with Testcontainers
- Clean CI/CD pipelines
- No hidden threads or background services
- Reuse in CLI tools, workers, APIs, and serverless contexts
๐ฆ Dependencies
This package depends on:
Confluent.Kafka (2.3.0)
Core Kafka client implementationFranz.Common.Messaging
Core messaging abstractions and contractsFranz.Common.Annotations
Messaging and modeling annotations
โ ๏ธ Hosting integration is intentionally excluded. Use Franz.Common.Messaging.Hosting.Kafka for background listeners.
๐ฅ Installation
From NuGet
dotnet add package Franz.Common.Messaging.Kafka
๐ Usage
1๏ธโฃ Register Kafka Transport
using Franz.Common.Messaging.Kafka.Extensions;
public void ConfigureServices(IServiceCollection services)
{
services.AddKafkaMessaging(configuration);
}
This registers:
- Kafka producers
- Kafka senders
- Kafka consumers (transport only)
No hosted services are started.
2๏ธโฃ Publish Messages
public class OrderPublisher
{
private readonly IMessagingPublisher _publisher;
public OrderPublisher(IMessagingPublisher publisher)
{
_publisher = publisher;
}
public async Task PublishAsync(OrderCreatedEvent evt)
{
await _publisher.PublishAsync(evt);
}
}
3๏ธโฃ Send Messages
public class PaymentSender
{
private readonly IMessagingSender _sender;
public PaymentSender(IMessagingSender sender)
{
_sender = sender;
}
public async Task SendAsync(PaymentCommand command)
{
await _sender.SendAsync(command);
}
}
4๏ธโฃ Kafka Consumers (Important)
Franz does not re-abstract Kafka consumers.
Consumers are provided directly by Confluent:
IConsumer<string, string>
They are:
- Created by
IKafkaConsumerFactory - Registered as long-lived singletons
- Fully compatible with Confluent.Kafka tooling and documentation
This avoids:
- Interface drift
- Partial re-implementations
- Subtle incompatibilities during upgrades
๐งช Testing & CI
This design is fully compatible with:
- Testcontainers (Kafka)
- Azure DevOps pipelines
- Docker-based integration tests
- Local developer environments
Because:
- No background services auto-start
- No implicit threads are created
- Kafka consumers are explicit and controlled
๐ Integration with the Franz Framework
This package integrates with:
- Franz.Common.Messaging
- Franz.Common.Messaging.Hosting.Kafka (optional, for background execution)
- Franz.Common.Mediator
- Franz.Common.EntityFramework
- Franz.Common.Business
Kafka is treated as a transport, not an execution model.
๐งพ Versioning & Changelog
Current Version: v2.3.0
Version 1.7.01
- ๐งฑ Corrected transport vs hosting separation
- ๐ Removed Kafka consumer re-abstraction
- ๐ญ Centralized consumer creation via
IKafkaConsumerFactory - โป๏ธ Fixed DI lifetimes for Kafka consumers
- ๐งฉ Clean separation between messaging and hosting layers
- ๐งช Improved Testcontainers and CI reliability
v2.0.2 โ Internal Modernization
- Messaging and infrastructure refactored for async, thread-safety, and modern .NET 10 patterns.
- Full granular control of KafkaMessagingOptions.
- All APIs remain fully backward compatible.
- Tests, listeners, and pipeline components modernized.
2.0.7 โ Kafka Registration now handles per Event registration automatically, no need to specify each event type manually.
๐ License
MIT License
See the LICENSE file for details.
๐ง Final Note
This package intentionally mirrors enterprise messaging frameworks (MassTransit, NServiceBus, Brighter) by enforcing:
Transport โ Hosting
That separation is what makes Franz:
- Predictable
- Testable
- Scalable
- Production-safe
Dependency maintenance โ October 2026
This project's dependency references were reviewed and updated as part of the repository-wide .NET 10 maintenance pass. The intended target framework and public API remain unchanged. Verify the resolved direct and transitive dependency graph through the repository's dependency validation workflow before publishing. See the central dependency upgrade record.
| 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
- Confluent.Kafka (>= 2.15.0)
- Franz.Common.Annotations (>= 2.3.1)
- Franz.Common.Hosting (>= 2.3.1)
- Franz.Common.Messaging (>= 2.3.1)
- Franz.Common.Messaging.Hosting (>= 2.3.1)
- SharpCompress (>= 0.50.7)
- Snappier (>= 1.3.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Franz.Common.Messaging.Kafka:
| Package | Downloads |
|---|---|
|
Franz.Common.Messaging.Hosting.Kafka
Shared utility library for the Franz Framework. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.3.1 | 96 | 10/26/2026 |
| 2.3.0 | 166 | 7/21/2026 |
| 2.2.19 | 147 | 7/19/2026 |
| 2.2.18 | 144 | 7/19/2026 |
| 2.2.17 | 154 | 7/12/2026 |
| 2.2.16 | 146 | 7/2/2026 |
| 2.2.15 | 148 | 6/29/2026 |
| 2.2.14 | 143 | 6/29/2026 |
| 2.2.13 | 148 | 6/29/2026 |
| 2.2.12 | 139 | 6/28/2026 |
| 2.2.11 | 141 | 6/28/2026 |
| 2.2.10 | 140 | 6/28/2026 |
| 2.2.9 | 149 | 6/28/2026 |
| 2.2.8 | 143 | 6/28/2026 |
| 2.2.7 | 155 | 6/7/2026 |
| 2.2.6 | 152 | 6/6/2026 |
| 2.2.5 | 155 | 6/4/2026 |
| 2.2.4 | 146 | 6/3/2026 |
| 2.2.3 | 172 | 6/2/2026 |
| 2.2.2 | 181 | 6/2/2026 |