// Collection of code snippets by Arne Vajhøj // (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) using System; using System.Collections.Generic; using System.Text; using Confluent.Kafka; using Confluent.Kafka.Serialization; namespace KProducer { public class Program { private const string SERVER = "localhost:9092"; private const string TNAME = "TestT"; private const string PAYLOAD = "\r\n 123\r\n ABC\r\n"; public static void Main(string[] args) { IDictionary cfg = new Dictionary(); cfg.Add("bootstrap.servers", SERVER); using (Producer sender = new Producer(cfg, new IntSerializer(), new StringSerializer(Encoding.UTF8))) { for (int i = 0; i < 3; i++) { sender.ProduceAsync(TNAME, i, PAYLOAD); } sender.Flush(); } } } }