private static PublishMessageToKafka KafkaProducerBuilder(string bootstrapServers) { var producerConfig = new ProducerConfig { BootstrapServers = bootstrapServers, Acks = Acks.All }; var kafkaProducer = new ProducerBuilder <int, string>(producerConfig).Build(); var publishMessageToKafka = new PublishMessageToKafka(kafkaProducer); return(publishMessageToKafka); }
static async Task Main() { var topic = "OrderEventQA2"; var bootstrapServers = "127.0.0.1:9092"; CreateKafkaTopics.Create(false); PublishMessageToKafka publishMessageToKafka = KafkaProducerBuilder(bootstrapServers); await publishMessageToKafka.Publish(topic); ConsumeMessageFromKafka consumeMessageFromKafka = KafkaConsumerBuilder(bootstrapServers); consumeMessageFromKafka.Consume(topic); }