Exemplo n.º 1
0
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            ConsoleTrace.Log("RuleEngine Started");

            while (!stoppingToken.IsCancellationRequested)
            {
                try
                {
                    _ruleActivator.ActivateRules();
                }
                catch (Exception ex)
                {
                    ConsoleTrace.LogError(ex.Message);

                    continue;
                }

                ConsoleTrace.Log("Rules Activated");
                Thread.Sleep(Timeout.Infinite);
            }
        }
        public void ActivateListener()
        {
            using (var scope = _serviceScopeFactory.CreateScope())
            {
                try
                {
                    var kafkaReceiver = scope.ServiceProvider.GetService <IMessageQueueReceiver>();

                    kafkaReceiver.GroupId         = TopicName;
                    kafkaReceiver.TopicPartitions = new List <(string, int)>()
                    {
                        (TopicName, Partition)
                    };
                    kafkaReceiver.OnMessageReceived += ExecutePackager;
                    kafkaReceiver.ReceiveInNewThread();
                }
                catch (Exception ex)
                {
                    ConsoleTrace.LogError(ex.Message);
                }
            }
        }