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                
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.Kafka" Version="1.2.62" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Franz.Common.Messaging.Kafka --version 1.2.62                
#r "nuget: Franz.Common.Messaging.Kafka, 1.2.62"                
#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.
// 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 and ConnectionFactoryProvider for managing Kafka connections and factories.
  • Kafka Consumers:
    • KafkaConsumerGroup and KafkaConsumerProvider for managing consumer groups.
  • Modeling:
    • KafkaModel and ModelProvider for managing and interacting with Kafka models.
  • Serialization:
    • Includes IMessageDeserializer and JsonMessageDeserializer for message serialization and deserialization.
  • Transactions:
    • Tools like MessagingTransaction, KafkaSender, and KafkaConsumerFactory for handling messaging transactions.
  • Hosting Support:
    • Listener to enable Kafka-based message listening in hosting scenarios.
  • Utilities:
    • Helper classes like ExchangeNamer and TopicNamer for topic management.
  • 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:

  1. Clone the repository.
  2. Create a feature branch.
  3. 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 and KafkaConsumerGroup for connection and consumer management.
  • Introduced KafkaSender and KafkaConsumerFactory for producer and consumer workflows.
  • Added serialization utilities with JsonMessageDeserializer.
  • Full integration with Franz.Common.Messaging and Franz.Common.Hosting.
Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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