Franz.Common.Messaging.Kafka
1.6.15
dotnet add package Franz.Common.Messaging.Kafka --version 1.6.15
NuGet\Install-Package Franz.Common.Messaging.Kafka -Version 1.6.15
<PackageReference Include="Franz.Common.Messaging.Kafka" Version="1.6.15" />
<PackageVersion Include="Franz.Common.Messaging.Kafka" Version="1.6.15" />
<PackageReference Include="Franz.Common.Messaging.Kafka" />
paket add Franz.Common.Messaging.Kafka --version 1.6.15
#r "nuget: Franz.Common.Messaging.Kafka, 1.6.15"
#:package Franz.Common.Messaging.Kafka@1.6.15
#addin nuget:?package=Franz.Common.Messaging.Kafka&version=1.6.15
#tool nuget:?package=Franz.Common.Messaging.Kafka&version=1.6.15
Franz.Common.Messaging.Kafka
A Kafka integration library within the Franz Framework designed to simplify interaction with Kafka topics, producers, and consumers. This package provides tools for creating and managing Kafka connections, handling serialization, and integrating Kafka workflows into distributed systems.
Features
- Kafka Connections:
ConnectionProviderandConnectionFactoryProviderfor managing Kafka connections and factories.
- Kafka Consumers:
KafkaConsumerGroupandKafkaConsumerProviderfor managing consumer groups.
- Modeling:
KafkaModelandModelProviderfor managing and interacting with Kafka models.
- Serialization:
- Includes
IMessageDeserializerandJsonMessageDeserializerfor message serialization and deserialization.
- Includes
- Transactions:
- Tools like
MessagingTransaction,KafkaSender, andKafkaConsumerFactoryfor handling messaging transactions.
- Tools like
- Hosting Support:
Listenerto enable Kafka-based message listening in hosting scenarios.
- Utilities:
- Helper classes like
ExchangeNamerandTopicNamerfor topic management.
- Helper classes like
- Extensions:
ServiceCollectionExtensionsfor streamlined service registration.
Version Information
- Current Version: 1.6.15
- Part of the private Franz Framework ecosystem.
Dependencies
This package relies on:
- Confluent.Kafka (2.3.0): Provides the core Kafka client functionality.
- Franz.Common.Annotations: For custom annotations used in Kafka models.
- Franz.Common.Hosting: Enables hosting support for Kafka listeners.
- Franz.Common.Messaging: Core messaging utilities and abstractions.
- Franz.Common.Messaging.Hosting: Adds hosting integration for messaging workflows.
Installation
From Private Azure Feed
Since this package is hosted privately, configure your NuGet client:
dotnet nuget add source "https://your-private-feed-url" \
--name "AzurePrivateFeed" \
--username "YourAzureUsername" \
--password "YourAzurePassword" \
--store-password-in-clear-text
Install the package:
dotnet add package Franz.Common.Messaging.Kafka
Usage
1. Register Kafka Services
Use ServiceCollectionExtensions to register Kafka services:
using Franz.Common.Messaging.Kafka.Extensions;
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddKafkaMessaging(options =>
{
options.BootstrapServers = "localhost:9092";
options.ClientId = "my-client-id";
});
}
}
2. Consume Kafka Messages
Set up a Kafka consumer group and process messages:
using Franz.Common.Messaging.Kafka.Consumers;
public class KafkaConsumerService
{
private readonly IKafkaConsumerFactory _consumerFactory;
public KafkaConsumerService(IKafkaConsumerFactory consumerFactory)
{
_consumerFactory = consumerFactory;
}
public async Task StartConsumingAsync()
{
var consumer = _consumerFactory.CreateConsumer("my-group", "my-topic");
await foreach (var message in consumer.ConsumeAsync())
{
Console.WriteLine($"Received message: {message.Value}");
}
}
}
3. Produce Kafka Messages
Send messages to a Kafka topic:
using Franz.Common.Messaging.Kafka;
public class KafkaProducerService
{
private readonly KafkaSender _kafkaSender;
public KafkaProducerService(KafkaSender kafkaSender)
{
_kafkaSender = kafkaSender;
}
public async Task SendMessageAsync(string topic, string key, string value)
{
await _kafkaSender.SendAsync(topic, key, value);
}
}
4. Serialize and Deserialize Messages
Use JsonMessageDeserializer for deserializing Kafka messages:
using Franz.Common.Messaging.Kafka.Serialisation;
var deserializer = new JsonMessageDeserializer<MyModel>();
var myModel = deserializer.Deserialize(message.Value);
Integration with Franz Framework
The Franz.Common.Messaging.Kafka package integrates seamlessly with:
- Franz.Common.Messaging: Provides foundational messaging utilities.
- Franz.Common.Hosting: Enables hosting support for Kafka listeners.
- Confluent.Kafka: Core Kafka client functionality for producers and consumers.
Contributing
This package is part of a private framework. Contributions are limited to the internal development team. If you have access, follow these steps:
- Clone the repository. @ https://github.com/bestacio89/Franz.Common/
- Create a feature branch.
- Submit a pull request for review.
License
This library is licensed under the MIT License. See the LICENSE file for more details.
Changelog
Version 1.2.65
- Added
ConnectionFactoryProviderandKafkaConsumerGroupfor connection and consumer management. - Introduced
KafkaSenderandKafkaConsumerFactoryfor producer and consumer workflows. - Added serialization utilities with
JsonMessageDeserializer. - Full integration with Franz.Common.Messaging and Franz.Common.Hosting.
Version 1.3
- Upgraded to .NET 9.0.8
- Added new features and improvements
- Separated business concepts from mediator concepts
- Now compatible with both the in-house mediator and MediatR
Version 1.3.6
- Integrated with Franz.Mediator (no MediatR).
- MessagingPublisher.Publish is now async Task.
- MessagingInitializer scans INotificationHandler<> for events.
- Kafka topics auto-created for all integration events.
| 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
- Confluent.Kafka (>= 2.11.1)
- Franz.Common.Annotations (>= 1.6.15)
- Franz.Common.Hosting (>= 1.6.15)
- Franz.Common.Messaging (>= 1.6.15)
- Franz.Common.Messaging.Hosting (>= 1.6.15)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on Franz.Common.Messaging.Kafka:
| Package | Downloads |
|---|---|
|
Franz.Common.Messaging.Bootstrap
Shared utility library for the Franz Framework. |
|
|
Franz.Common.Http.Messaging
Shared utility library for the Franz Framework. |
|
|
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 |
|---|---|---|
| 1.6.15 | 107 | 10/20/2025 |
| 1.6.14 | 187 | 10/15/2025 |
| 1.6.3 | 195 | 10/9/2025 |
| 1.6.2 | 194 | 10/7/2025 |
| 1.5.9 | 190 | 9/24/2025 |
| 1.5.4 | 186 | 9/23/2025 |
| 1.5.3 | 234 | 9/21/2025 |
| 1.5.2 | 231 | 9/21/2025 |
| 1.5.0 | 230 | 9/21/2025 |
| 1.4.4 | 216 | 9/20/2025 |
| 1.3.14 | 314 | 9/18/2025 |
| 1.3.13 | 307 | 9/18/2025 |
| 1.3.5 | 316 | 9/17/2025 |
| 1.3.4 | 308 | 9/16/2025 |
| 1.3.3 | 304 | 9/16/2025 |
| 1.3.2 | 303 | 9/15/2025 |
| 1.3.1 | 109 | 9/12/2025 |
| 1.3.0 | 308 | 8/25/2025 |
| 1.2.65 | 211 | 3/3/2025 |
| 1.2.64 | 155 | 1/29/2025 |
| 1.2.63 | 144 | 1/27/2025 |
| 1.2.62 | 157 | 1/8/2025 |