Skip to content

Kafka: Producers

ronimizy edited this page Feb 3, 2024 · 6 revisions

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.

Samples

Extensions.cs contains sample registration code for direct and outbox producers.