VOOZH about

URL: https://www.nuget.org/packages/ISC.Kafka.Extensions.Publisher/

⇱ NuGet Gallery | ISC.Kafka.Extensions.Publisher 1.0.0




ISC.Kafka.Extensions.Publisher 1.0.0

dotnet add package ISC.Kafka.Extensions.Publisher --version 1.0.0
 
 
NuGet\Install-Package ISC.Kafka.Extensions.Publisher -Version 1.0.0
 
 
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="ISC.Kafka.Extensions.Publisher" Version="1.0.0" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ISC.Kafka.Extensions.Publisher" Version="1.0.0" />
 
Directory.Packages.props
<PackageReference Include="ISC.Kafka.Extensions.Publisher" />
 
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 ISC.Kafka.Extensions.Publisher --version 1.0.0
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: ISC.Kafka.Extensions.Publisher, 1.0.0"
 
 
#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 ISC.Kafka.Extensions.Publisher@1.0.0
 
 
#: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=ISC.Kafka.Extensions.Publisher&version=1.0.0
 
Install as a Cake Addin
#tool nuget:?package=ISC.Kafka.Extensions.Publisher&version=1.0.0
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

ISC.Kafka.Extensions.Publisher

ISC.Kafka.Extensions.Publisher is a lightweight .NET package for publishing messages to Kafka.

It provides two main integration flows:

  1. Structured logging flow with IElasticLogger (log model is built and serialized automatically).
  2. Raw message publishing flow with IKafkaPublisher (full control over your payload).

Requirements

  • .NET 8+
  • A reachable Kafka cluster
  • Topic(s) created in Kafka

Flow 1: Use IElasticLogger for structured log publishing

Use this flow when you want to publish logs in a standard model (LoggerModel<T>) with:

  • CreateDate
  • LogLevel
  • HttpStatus
  • Url
  • Method
  • RequestBody
  • Resource (ServiceName)
  • ClientId (resolved from HttpContext.Items[Global.RESOURCE])

1) Configure options

using ISC.Kafka.Extensions.Publisher.Logging;

var loggerOptions = new ElasticLoggerModelOption
{
 BootstrapServers = "localhost:9092",
 Topic = "app-logs",
 Username = "",
 Password = "",
 ServiceName = "OrderService"
};

2) Create logger instance

IElasticLogger elasticLogger = new ElasticLogger(loggerOptions);

3) Publish logs

elasticLogger.Information(
 message: "Create order success",
 requestBody: "{\"orderId\":\"ORD-001\"}",
 httpStatus: 200,
 url: "/api/orders",
 method: "POST");

await elasticLogger.ErrorAsync(
 message: "Create order failed",
 requestBody: "{\"orderId\":\"ORD-002\"}",
 httpStatus: 500,
 url: "/api/orders",
 method: "POST");

4) Set per-request client id (ASP.NET Core)

ElasticLogger reads ClientId from:

HttpContext.Items[Global.RESOURCE]

Example middleware:

using ISC.Kafka.Extensions.Publisher.SeedWork;

app.Use(async (context, next) =>
{
 context.Items[Global.RESOURCE] = context.Request.Headers["x-client-id"].ToString();
 await next();
});

Flow 2: Use IKafkaPublisher for raw message publishing

Use this flow when you want direct control over message content and key.

1) Create publisher

using ISC.Kafka.Extensions.Publisher;

IKafkaPublisher publisher = new KafkaPublisher(
 bootstrapServers: "localhost:9092",
 topic: "order-events",
 username: "",
 password: "");

2) Publish with PubMessageCustomAsync

var payload = new
{
 EventName = "OrderCreated",
 OrderId = "ORD-1001",
 CreatedAt = DateTime.UtcNow
};

var message = System.Text.Json.JsonSerializer.Serialize(payload);
await publisher.PubMessageCustomAsync(message, messageKey: "ORD-1001");

Notes

  • Prefer async APIs (ErrorAsync, InformationAsync, PubMessageCustomAsync) for non-blocking I/O.
  • ElasticLogger truncates very large requestBody values to avoid oversized Kafka messages.
  • Ensure the target topic and broker security settings match your environment.
Product Versions Compatible and additional computed target framework versions.
.NET net8.0 net8.0 is compatible.  net8.0-android net8.0-android was computed.  net8.0-browser net8.0-browser was computed.  net8.0-ios net8.0-ios was computed.  net8.0-maccatalyst net8.0-maccatalyst was computed.  net8.0-macos net8.0-macos was computed.  net8.0-tvos net8.0-tvos was computed.  net8.0-windows net8.0-windows was computed.  net9.0 net9.0 was computed.  net9.0-android net9.0-android was computed.  net9.0-browser net9.0-browser was computed.  net9.0-ios net9.0-ios was computed.  net9.0-maccatalyst net9.0-maccatalyst was computed.  net9.0-macos net9.0-macos was computed.  net9.0-tvos net9.0-tvos was computed.  net9.0-windows net9.0-windows was computed.  net10.0 net10.0 was computed.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows 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.0 113 3/30/2026