Eventuous dotnet kafka
Skill Eventuous/eventuous-plugin/skills/eventuous-dotnet-kafka
This skill should be used when configuring Kafka integration with Eventuous. Covers KafkaBasicProducer for publishing to Kafka topics, Confluent.Kafka configuration, partition keys, message headers, and produce options. Common triggers: 'publish events to Kafka', 'Kafka producer', 'Kafka topic', 'KafkaBasicProducer', 'Confluent.Kafka with Eventuous'.From its SKILL.md
npx -y skills add Eventuous/eventuous-plugin --skill eventuous-dotnet-kafkaAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
- 1 stars1 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
4.2 KB, as published. Nobody here has run it
Eventuous Kafka Integration
NuGet package: Eventuous.Kafka
Namespace: Eventuous.Kafka.Producers, Eventuous.Kafka.Subscriptions
Source: src/Kafka/src/Eventuous.Kafka/
Uses Confluent.Kafka under the hood. Produces byte[] payloads with type info in Kafka headers (no schema registry).
Producer
KafkaBasicProducer extends BaseProducer<KafkaProduceOptions> and implements IHostedProducer, IAsyncDisposable.
// Constructor takes KafkaProducerOptions (wraps Confluent ProducerConfig)
public record KafkaProducerOptions(ProducerConfig ProducerConfig);
// Per-message produce options (partition key)
public record KafkaProduceOptions(string PartitionKey);
Instantiation
var options = new KafkaProducerOptions(new ProducerConfig {
BootstrapServers = "localhost:9092"
});
await using var producer = new KafkaBasicProducer(options);
await producer.StartAsync(cancellationToken);
// Produce with partition key
await producer.Produce(
new StreamName("my-topic"),
events,
new Metadata(),
new KafkaProduceOptions("my-partition-key"),
cancellationToken: ct
);
DI Registration
services.AddProducer<KafkaBasicProducer>(sp =>
new KafkaBasicProducer(
new KafkaProducerOptions(new ProducerConfig {
BootstrapServers = "localhost:9092"
})
)
);
How it works
- Serializes events using
IEventSerializer, sends asbyte[]values - Stores event type in
message-typeheader and content type incontent-typeheader (configurable viaKafkaHeaderKeys) - When
PartitionKeyis provided, uses a keyed producer (IProducer<string, byte[]>); otherwise usesIProducer<Null, byte[]> - Metadata entries are converted to Kafka headers via
MetadataExtensions.AsKafkaHeaders() - Supports delivery acknowledgement callbacks (
OnAck/OnFail) StopAsyncflushes pending messages before stopping
Header Keys
public static class KafkaHeaderKeys {
public static string MessageTypeHeader { get; set; } = "message-type";
public static string ContentTypeHeader { get; set; } = "content-type";
}
Gateway Integration
To forward events from an event store subscription to Kafka topics, use the Eventuous Gateway. The stream name becomes the Kafka topic name. See the eventuous-dotnet-gateway skill for full gateway configuration details.
services.AddGateway<
AllStreamSubscription,
AllStreamSubscriptionOptions,
KafkaBasicProducer,
KafkaProduceOptions
>(
"events-to-kafka",
KafkaGateway.Transform
);
Key Behaviors
- Topic mapping: The stream name passed to
Producebecomes the Kafka topic name - Partition key: When using
KafkaProduceOptionswith aKey, messages with the same key go to the same partition (ordering guarantee) - Headers: Each message includes
message-typeandcontent-typeheaders, plus all metadata entries as additional headers - Flush on stop: The producer flushes pending messages when the hosted service stops
- Keyed vs unkeyed:
KafkaBasicProducerhas two internal producers — one for keyed messages (with partition key) and one for unkeyed (round-robin)
Subscription
KafkaBasicSubscription extends EventSubscription<KafkaSubscriptionOptions>. Note: the subscription is currently a stub (throws NotImplementedException).
public record KafkaSubscriptionOptions : SubscriptionOptions {
public ConsumerConfig ConsumerConfig { get; init; } = null!;
}
Note: The Kafka subscription is not yet implemented. For consuming Kafka messages in Eventuous event handlers, use
Confluent.Kafka'sConsumerBuilderdirectly and route messages through your application layer. This limitation is tracked for a future release.
Tracing
Built-in OpenTelemetry tracing with:
MessagingSystem = "kafka"DestinationKind = "topic"ProduceOperation = "produce"