public KafkaProducer(ILogger <KafkaProducer> logger, KafkaConfiguration configuration)
        {
            ProducerConfig producerConfig = new ProducerConfig
            {
                BootstrapServers = configuration.Servers,
                MessageTimeoutMs = 10000,
                Acks             = Acks.Leader
            };

            _producer = new ProducerBuilder <Null, string>(producerConfig).Build();
            _logger   = logger;
        }
示例#2
0
        public KafkaConsumer(ILogger <KafkaConsumer> logger, KafkaConfiguration configuration, ISubscriptionManager subscriptionManager, IMediator mediator)
        {
            ConsumerConfig consumerConfig = new ConsumerConfig
            {
                BootstrapServers = configuration.Servers,
                GroupId          = configuration.ConsumerGroupId,
                AutoOffsetReset  = AutoOffsetReset.Latest,
                Acks             = Acks.Leader
            };

            _consumerConfig      = consumerConfig;
            _logger              = logger;
            _subscriptionManager = subscriptionManager;
            _mediator            = mediator;
        }