Tributary.Kafka.Producer 1.0.1

dotnet add package Tributary.Kafka.Producer --version 1.0.1
                    
NuGet\Install-Package Tributary.Kafka.Producer -Version 1.0.1
                    
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="Tributary.Kafka.Producer" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Tributary.Kafka.Producer" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="Tributary.Kafka.Producer" />
                    
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 Tributary.Kafka.Producer --version 1.0.1
                    
#r "nuget: Tributary.Kafka.Producer, 1.0.1"
                    
#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 Tributary.Kafka.Producer@1.0.1
                    
#: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=Tributary.Kafka.Producer&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=Tributary.Kafka.Producer&version=1.0.1
                    
Install as a Cake Tool

Tributary.Kafka.Producer

A .NET Kafka producer with sensible defaults. Wraps Akka.NET Streams Kafka under an opinionated, config-driven API.

dotnet add package Tributary.Kafka.Producer

Bootstrap

builder.Services.AddSharedKafkaProducer(builder.Configuration);

Publish

public sealed class OrdersService
{
    private readonly IEventProducer _producer;

    public OrdersService(IEventProducer producer) => _producer = producer;

    public Task PublishAsync(OrderPlacedEvent evt, CancellationToken ct) =>
        _producer.PublishAsync(
            topic: "orders.placed",
            message: evt,
            key: evt.OrderId,
            options: new PublishOptions
            {
                TenantId = "tenant_001",
                EventType = "OrderPlaced"
            },
            cancellationToken: ct);
}

Every message is wrapped in an EventEnvelope<T> with auto-generated EventId, EventType, OccurredAt, and optional TenantId. The same fields are also attached as Kafka headers (event-id, event-type, occurred-at, tenant-id).

Config

{
  "Kafka": {
    "BootstrapServers": "your-broker:9092",
    "SecurityProtocol": "SASL_SSL",
    "SaslMechanism": "SCRAM-SHA-256",
    "SaslUsername": "your-user",
    "SaslPassword": "your-password",
    "ClientId": "my-service-producer",
    "EnableIdempotence": true
  }
}

The producer applies only the properties you set, so the same code works against Aiven, AWS MSK, Confluent Cloud, or self-hosted Kafka — just change config.

For mTLS (e.g. Aiven Client Certificate auth), use SslCaLocation, SslCertificateLocation, SslKeyLocation instead of the SASL fields.

Idempotent producer (default on)

EnableIdempotence defaults to true, which automatically sets enable.idempotence=true and acks=all. This gives you exactly-once delivery at the producer→broker boundary (no duplicate writes on network retries) for negligible cost. Set to false only if you have a specific reason (legacy broker, throughput-critical fire-and-forget).

Failure handling

PublishAsync throws Confluent.Kafka.ProduceException on failure. The SDK does not swallow errors — your caller decides whether to retry, log, dead-letter, or fail the upstream request.

Common error codes:

Error Cause
UnknownTopicOrPart Topic doesn't exist — create it or enable broker auto-create
BrokerNotAvailable / NetworkException Can't reach brokers — check bootstrap servers + network
AuthenticationFailed Bad mTLS cert or SASL credentials
MessageSizeTooLarge Exceeds broker's message.max.bytes
TopicAuthorizationFailed ACLs don't permit this client to write the topic

Pair with the consumer

See Tributary.Kafka.Consumer for the matching consumer-side SDK with attribute-driven topic binding, configurable commit mode, and optional idempotency.

License

MIT

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.  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.0.1 83 5/27/2026