Skip to content

Foundatio.Kafka ​

Foundatio provides Apache Kafka messaging for high-throughput event streaming. View source on GitHub →

Overview ​

ImplementationInterfacePackage
KafkaMessageBusIMessageBusFoundatio.Kafka

Installation ​

bash
dotnet add package Foundatio.Kafka

Usage ​

csharp
using Foundatio.Messaging;

var messageBus = new KafkaMessageBus(o =>
{
    o.BootstrapServers = "localhost:9092";
    o.Topic = "events";
    o.GroupId = "my-service";
});

await messageBus.SubscribeAsync<OrderCreated>(async order =>
{
    Console.WriteLine($"Order created: {order.OrderId}");
});

await messageBus.PublishAsync(new OrderCreated { OrderId = 123 });

Configuration ​

OptionTypeRequiredDescription
BootstrapServersstring✅Kafka broker addresses
GroupIdstring✅Consumer group ID
SecurityProtocolSecurityProtocol?Security protocol
SaslMechanismSaslMechanism?SASL mechanism
SaslUsernamestringSASL username
SaslPasswordstringSASL password

For additional options, see KafkaMessageBusOptions source.

Next Steps ​

Released under the Apache 2.0 License.