Ejemplo n.º 1
0
        public KafkaMessageFlowReceiverSettings CreateReceiverSettings(IMessageFlow messageFlow)
        {
            var topics = new List <string>();

            if (messageFlow.Equals(KafkaFactsFlow.Instance))
            {
                topics.Add(ConfigFileSetting.String.Required("AmsFactsTopic").Value);
                topics.Add(ConfigFileSetting.String.Required("RulesetFactsTopic").Value);
                topics.Add(ConfigFileSetting.String.Required("InfoRussiaFactsTopic").Value);
                topics.Add(ConfigFileSetting.String.Required("FijiFactsTopic").Value);
            }
            else if (messageFlow.Equals(AmsFactsFlow.Instance))
            {
                topics.Add(ConfigFileSetting.String.Required("AmsFactsTopic").Value);
            }
            else if (messageFlow.Equals(RulesetFactsFlow.Instance))
            {
                topics.Add(ConfigFileSetting.String.Required("RulesetFactsTopic").Value);
            }
            else if (messageFlow.Equals(InfoRussiaFactsFlow.Instance))
            {
                topics.Add(ConfigFileSetting.String.Required("InfoRussiaFactsTopic").Value);
            }
            else if (messageFlow.Equals(FijiFactsFlow.Instance))
            {
                topics.Add(ConfigFileSetting.String.Required("FijiFactsTopic").Value);
            }

            if (topics.Count == 0)
            {
                throw new ArgumentException($"Unknown message flows provided");
            }

            return(new KafkaMessageFlowReceiverSettings
            {
                Config = _kafkaConfig,
                TopicPartitionOffsets = topics.Select(x => new TopicPartitionOffset(x, Partition.Any, Offset.Unset))
            });
        }
Ejemplo n.º 2
0
        public KafkaMessageFlowReceiverSettings CreateReceiverSettings(IMessageFlow messageFlow)
        {
            var settings = _wrap.CreateReceiverSettings(messageFlow);

            // stateinit всегда начинает читать все partitions с Offset.Beginning
            settings.TopicPartitionOffsets = settings.TopicPartitionOffsets
                                             .Select(x => new TopicPartitionOffset(x.Topic, Partition.Any, Offset.Beginning));

            // хак для InfoRussia, интересные нам данные начинаются только с определённого offset
            if (messageFlow.Equals(InfoRussiaFactsFlow.Instance))
            {
                const long InfoRussiaOffset = 7_000_000;

                settings.TopicPartitionOffsets = settings.TopicPartitionOffsets.Select(x => new
                                                                                       TopicPartitionOffset(x.Topic, x.Partition, InfoRussiaOffset));
            }

            return(settings);
        }