예제 #1
0
        public KafkaProducer(KafkaSettings kafkaSettings, KafkaProducerSettings kafkaProducerSettings)
        {
            KafkaProducerSettings = kafkaProducerSettings;

            Producer = new Producer <string, string>(
                new Dictionary <string, object>()
            {
                {
                    "bootstrap.servers", $"{kafkaSettings.Host}:9092"
                },
                { "default.topic.config", new Dictionary <string, object>()
                  {
                      { "message.timeout.ms", 5000 }
                  } },
                { "message.send.max.retries", 0 }
            },
                new StringSerializer(Encoding.UTF8), new StringSerializer(Encoding.UTF8));
        }
예제 #2
0
        public KafkaConsumer(IMediator mediator, KafkaSettings kafkaSettings, KafkaConsumerSettings kafkaConsumerSettings)
        {
            Mediator = mediator;
            KafkaConsumerSettings = kafkaConsumerSettings;
            KafkaSettings         = kafkaSettings;

            Consumer = new Consumer <string, string>(
                new Dictionary <string, object>
            {
                { "group.id", KafkaConsumerSettings.GroupId },
                { "enable.auto.commit", true },
                { "auto.commit.interval.ms", 5000 },
                { "statistics.interval.ms", 60000 },
                { "bootstrap.servers", $"{kafkaSettings.Host}:9092" },
                { "default.topic.config", new Dictionary <string, object>()
                  {
                      { "auto.offset.reset", "smallest" }
                  } }
            }, new StringDeserializer(Encoding.UTF8), new StringDeserializer(Encoding.UTF8));
        }