-
Notifications
You must be signed in to change notification settings - Fork 0
Kafka: Producers
To use producer, you do not need to implement any interfaces. You can get an instance of IKafkaMessageProducer<,>
from DI container.
Use ProduceAsync
method to produce messages. It accepts IAsyncEnumberable<KafkaConsumerMessage<,>>
and has an extension overload for accepting a single KafkaConsumerMessage<,>
.
Before that, you have to register a consumer with type arguments corresponding to message key and value respectfully.
See producer configuration Wiki for registration documentation and samples.
When using outbox producer, you still have to get IKafkaMessageProducer<,>
instance from DI container. Only difference is in configuration, see outbox configuration Wiki for documentation.
- https://github.com/itmo-is-dev/platform/tree/master/samples/Itmo.Dev.Platform.Kafka.Samples/Producer
Extensions.cs
contains sample registration code for direct and outbox producers.