Exemplo n.º 1
0
        public KafkaMessageProducer(KafkaMessagingGatewayConfiguration globalConfiguration,
                                    KafkaMessagingProducerConfiguration producerConfiguration)
        {
            var serialiser = new StringSerializer(Encoding.UTF8);
            var config     = globalConfiguration.ToConfig();

            config    = config.Concat(producerConfiguration.ToConfig());
            _producer = new Producer <Null, string>(config, null, serialiser);
        }
Exemplo n.º 2
0
        public KafkaMessageProducer(KafkaMessagingGatewayConfiguration globalConfiguration,
                                    KafkaMessagingProducerConfiguration producerConfiguration)
        {
            _producerConfig = new ProducerConfig
            {
                BootstrapServers          = string.Join(",", globalConfiguration.BootStrapServers),
                ClientId                  = globalConfiguration.Name,
                MaxInFlight               = globalConfiguration.MaxInFlightRequestsPerConnection,
                QueueBufferingMaxMessages = producerConfiguration.QueueBufferingMaxMessages,
                Acks = producerConfiguration.Acks,
                QueueBufferingMaxKbytes = producerConfiguration.QueueBufferingMaxKbytes,
                MessageSendMaxRetries   = producerConfiguration.MessageSendMaxRetries,
                BatchNumMessages        = producerConfiguration.BatchNumberMessages,
                LingerMs         = producerConfiguration.QueueBufferingMax,
                RequestTimeoutMs = producerConfiguration.RequestTimeout,
                MessageTimeoutMs = producerConfiguration.MessageTimeout,
                RetryBackoffMs   = producerConfiguration.RetryBackoff
            };

            _producer = new ProducerBuilder <Null, string>(_producerConfig).Build();
        }