using System; using System.Threading.Tasks; using Confluent.Kafka; using Model; class Producer { public static async Task Main (string[] args) { var config = new ProducerConfig { BootstrapServers = "localhost:9092" }; using (var producerBuilder = new ProducerBuilder(config).Build()) { try { var msg = new Message { Key = System.Guid.NewGuid().ToString(), Value = new DataModel(System.Guid.NewGuid().ToString()) { name = "Name", description = "Description", notes = "This is a test object" } }; var dr = await producerBuilder.ProduceAsync("test-topic", msg); Console.WriteLine($"Delivered '{dr.Value}' to '{dr.TopicPartitionOffset}'"); } catch (ProduceException e) { Console.WriteLine($"Delivery failed: {e.Error.Reason}"); } } } }