public KafkaConsumer(string groupId, string kafkaServerURL, string topic) { serializer = new KafkaSerializer <T>(); cts = new CancellationTokenSource(); Queue = new BlockingCollectionQueue <T>(); ErrorsQueue = new BlockingCollectionQueue <string>(); KafkaServerURL = kafkaServerURL; Topic = topic; Config = new ConsumerConfig { GroupId = groupId, BootstrapServers = KafkaServerURL, AutoOffsetReset = AutoOffsetReset.Earliest, }; }
public KafkaProducer(string kafkaServerURL, string topic, KafkaSerializer <T> serializer) { Serializer = serializer; KafkaServerURL = kafkaServerURL; Topic = topic; Config = new ProducerConfig { BootstrapServers = KafkaServerURL, MessageTimeoutMs = 5000 }; ReportHandler = r => { if (r.Error.IsError) { OnError?.Invoke(this, $"Delivery Error: {r.Error.Reason}"); } else { ReportDelivery?.Invoke(this, $"Delivered to {r.TopicPartitionOffset}. Topic: {r.Topic}"); } }; }