public KafkaMessageProducer(KafkaServerConfiguration configuration, IUniqueIdentifier uniqueIdentifier) { this.configuration = configuration; this.uniqueIdentifier = uniqueIdentifier; producer = new ProducerBuilder <Null, IdentifiedMessage>(new ProducerConfig { BootstrapServers = configuration.ServerUrl }).SetValueSerializer(new CustomJsonSerializer <IdentifiedMessage>()).Build(); }
public KafkaMessageConsumer(KafkaServerConfiguration configuration, IUniqueIdentifier uniqueIdentifier) { this.configuration = configuration; this.uniqueIdentifier = uniqueIdentifier; consumer = new ConsumerBuilder <Ignore, IdentifiedMessage>(new ConsumerConfig { BootstrapServers = configuration.ServerUrl, GroupId = $"group-{Guid.NewGuid()}", AutoOffsetReset = AutoOffsetReset.Earliest, }).SetValueDeserializer(new CustomJsonDeserializer <IdentifiedMessage>()).Build(); consumer.Subscribe(configuration.TopicName); }