// 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 KConsumer { public class Program { private const string SERVER = "localhost:9092"; private const string TNAME = "TestT"; public static void Main(string[] args) { IDictionary cfg = new Dictionary(); cfg.Add("bootstrap.servers", SERVER); cfg.Add("group.id", "mygroup"); using (Consumer receiver = new Consumer(cfg, new IntDeserializer(), new StringDeserializer(Encoding.UTF8))) { receiver.OnMessage += (_, msg) => Console.Write("{0}:\r\n{1}\r\n", msg.Key, msg.Value); receiver.Subscribe(TNAME); while (true) { receiver.Poll(TimeSpan.FromMilliseconds(100)); } } } } }