Exemple #1
0
        public string GetBestQueue()
        {
            using (var sqlconn = new SQLiteConnection(EnvironmentHelper.GetValue(DictionaryConstants.DatabaseConnectionString)))
            {
                sqlconn.Open();

                try
                {
                    //SELECT * FROM MachinesConsume WHERE
                    var sqlcom = new SQLiteCommand($"Select MIN(CpuUsage) CpuUsage, MachineName from MachinesConsume", sqlconn);

                    var    reader      = sqlcom.ExecuteReader();
                    string machineName = Environment.MachineName;
                    while (reader.Read())
                    {
                        machineName = reader.GetString(1);
                    }

                    return(MqHelper.OrchestratorQueueName(machineName));
                }
                finally
                {
                    sqlconn.Close();
                    sqlconn.Dispose();
                }
            }
        }
Exemple #2
0
        private readonly List <RunningCrawler> runningCrawlers = new List <RunningCrawler>(); //Buscar do banco caso morra

        public Worker(ILogger <Worker> logger, IMessageQueueConnection mq, IDatabase db)
        {
            _logger = logger;
            _mq     = mq;
            _db     = db;

            _mq.CreateQueue(MqHelper.OrchestratorQueueName());
            _mq.ConfigureConsumeQueueListener(MqHelper.OrchestratorQueueName(), true, CreateCrawler);
        }