Franz.Common.Messaging.Kafka
1.2.62
dotnet add package Franz.Common.Messaging.Kafka --version 1.2.62
NuGet\Install-Package Franz.Common.Messaging.Kafka -Version 1.2.62
<PackageReference Include="Franz.Common.Messaging.Kafka" Version="1.2.62" />
paket add Franz.Common.Messaging.Kafka --version 1.2.62
#r "nuget: Franz.Common.Messaging.Kafka, 1.2.62"
// Install Franz.Common.Messaging.Kafka as a Cake Addin #addin nuget:?package=Franz.Common.Messaging.Kafka&version=1.2.62 // Install Franz.Common.Messaging.Kafka as a Cake Tool #tool nuget:?package=Franz.Common.Messaging.Kafka&version=1.2.62
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:
ConnectionProvider
andConnectionFactoryProvider
for managing Kafka connections and factories.
- Kafka Consumers:
KafkaConsumerGroup
andKafkaConsumerProvider
for managing consumer groups.
- Modeling:
KafkaModel
andModelProvider
for managing and interacting with Kafka models.
- Serialization:
- Includes
IMessageDeserializer
andJsonMessageDeserializer
for message serialization and deserialization.
- Includes
- Transactions:
- Tools like
MessagingTransaction
,KafkaSender
, andKafkaConsumerFactory
for handling messaging transactions.
- Tools like
- Hosting Support:
Listener
to enable Kafka-based message listening in hosting scenarios.
- Utilities:
- Helper classes like
ExchangeNamer
andTopicNamer
for topic management.
- Helper classes like
- Extensions:
ServiceCollectionExtensions
for streamlined service registration.
Version Information
- Current Version: 1.2.62
- 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 --version 1.2.62
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.
- 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.62
- Added
ConnectionFactoryProvider
andKafkaConsumerGroup
for connection and consumer management. - Introduced
KafkaSender
andKafkaConsumerFactory
for producer and consumer workflows. - Added serialization utilities with
JsonMessageDeserializer
. - Full integration with Franz.Common.Messaging and Franz.Common.Hosting.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. 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. |
-
net8.0
- Confluent.Kafka (>= 2.3.0)
- Franz.Common.Annotations (>= 1.2.62)
- Franz.Common.Hosting (>= 1.2.62)
- Franz.Common.Messaging (>= 1.2.62)
- Franz.Common.Messaging.Hosting (>= 1.2.62)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Franz.Common.Messaging.Kafka:
Package | Downloads |
---|---|
Franz.Common.Http.Messaging
Shared utility library for the Franz Framework. |
|
Franz.Common.Messaging.Bootstrap
Shared utility library for the Franz Framework. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.2.62 | 59 | 1/8/2025 |