示例#1
0
        public AffiliateCategoryKafkaConsumer(KafkaSettings settings, AffiliateCategoryDomainService domainService)
        {
            _domainService = domainService.ThrowIfNull(nameof(domainService));
            settings.ThrowIfNull(nameof(settings));

            _config = new ConsumerConfig
            {
                BootstrapServers = settings.BootstrapServers,
                SaslMechanism    = SaslMechanism.Plain,
                SecurityProtocol = SecurityProtocol.SaslSsl,
                SaslUsername     = settings.Username,
                SaslPassword     = settings.Password,
                ClientId         = settings.ClientId,
                GroupId          = settings.GroupId,
                AutoOffsetReset  = AutoOffsetReset.Earliest,
                EnableAutoCommit = false
            };
        }
示例#2
0
        public KafkaBus(KafkaSettings settings, IFailedEventRepository failedEventsEventRepository)
        {
            settings.ThrowIfNull(nameof(settings));
            _failedEventsEventRepository = failedEventsEventRepository.ThrowIfNull(nameof(failedEventsEventRepository));

            var config = new ProducerConfig
            {
                BootstrapServers      = settings.BootstrapServers,
                Acks                  = Acks.All,
                MessageSendMaxRetries = 10000000,
                SslEndpointIdentificationAlgorithm = SslEndpointIdentificationAlgorithm.Https,
                SaslMechanism    = SaslMechanism.Plain,
                SecurityProtocol = SecurityProtocol.SaslSsl,
                //SslCaLocation = "/usr/local/etc/openssl/cert.pem",
                SaslUsername = settings.Username,
                SaslPassword = settings.Password
            };

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