public KafkaConsumerWrapper(KafkaPubSubConfiguration configuration, ILoggerFactory loggerFactory, string group)
        {
            this.configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
            this.group         = group ?? throw new ArgumentNullException(nameof(group));
            logger             = loggerFactory?.CreateLogger <KafkaConsumerWrapper>() ?? throw new ArgumentNullException(nameof(loggerFactory));

            _kafkaConsumer = new Consumer(configuration.CreateKafkaConsumerConfigurationDictionary(group));
            KafkaConsumerEventsSubscribe();
        }
 public KafkaProducerWrapper(KafkaPubSubConfiguration configuration, ILoggerFactory loggerFactory)
 {
     this.configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
     logger             = loggerFactory?.CreateLogger <KafkaProducerWrapper>() ?? throw new ArgumentNullException(nameof(loggerFactory));
 }
Esempio n. 3
0
 public KafkaPubSub(KafkaPubSubConfiguration configuration, ILoggerFactory loggerFactory)
 {
     this.configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
     this.loggerFactory = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory));
     producer           = new KafkaProducerWrapper(configuration, loggerFactory);
 }
 public static IDictionary <string, object> CreateKafkaProducerConfigurationDictionary(this KafkaPubSubConfiguration configuration)
 {
     return(new Dictionary <string, object>
     {
         { "bootstrap.servers", configuration.BrokerList }
     });
 }
 public static IDictionary <string, object> CreateKafkaConsumerConfigurationDictionary(this KafkaPubSubConfiguration configuration, string groupId)
 {
     return(new Dictionary <string, object>
     {
         { "group.id", groupId },
         { "enable.auto.commit", false },
         { "bootstrap.servers", configuration.BrokerList },
         { "auto.offset.reset", "earliest" }
     });
 }