using Cloud.Services.Broker.Support; using Confluent.Kafka; namespace Cloud.Services.Broker.Implement.Kafka { public class KafkaProducer : IBrokerProducer { private readonly IProducer _producer; public KafkaProducer(IConfiguration configuration) { var producerConfig = new ProducerConfig { BootstrapServers = configuration["Kafka:BootstrapServers"] }; //Build the Producer _producer = new ProducerBuilder(producerConfig).Build(); } public async Task ProduceAsync(string topic, Command command) { var message = new Message { Key = Guid.NewGuid(), Value = command }; //Produce the Message await _producer.ProduceAsync(topic, message); } } }