Awesome Open Source
Awesome Open Source

NuGet version

kafka-net-core

This is the net core versions of the library kafka-net

Examples

Use .NET CLI

dotnet add package kafka-net-core --version 1.0.2
Producer
var options = new KafkaOptions(new Uri("http://localhost:9092"));
var router = new BrokerRouter(options);

using (Producer client = new Producer(router))
{
    client.SendMessageAsync("test_topic", new[] { new Message("hello world") }).Wait();
}
Consumer
var options = new KafkaOptions(new Uri("http://localhost:9092"));
var router = new BrokerRouter(options);
using (var consumer = new Consumer(new ConsumerOptions("test_topic", router)))
{
    // Consume returns a blocking IEnumerable (ie: never ending stream)
    foreach (var message in consumer.Consume())
    {
        Console.WriteLine("Response: P{0},O{1} : {2}",
            message.Meta.PartitionId, message.Meta.Offset, message.Value);
    }
}

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
C Sharp (278,472
Dotnet Core (4,340
Kafka (3,339
Netcore (1,553
Apache Kafka (271
Related Projects