コード例 #1
0
        static void Main(string[] args)
        {
            Server.ConnectionString        = ConfigCrawler.ConnectProduct;
            Server.LogConnectionString     = ConfigCrawler.ConnectLog;
            Server.ConnectionStringCrawler = ConfigCrawler.ConnectionCrawler;
            var companyId             = 480254425312154563;
            CancellationToken token1  = new CancellationToken();
            WorkerFindNew     wokerFn = new WorkerFindNew(companyId, token1, "");

            wokerFn.StartCrawler();
            return;

            Console.CancelKeyPress += EndApp;
            Parameter pt = new Parameter();

            QT.Entities.Server.ConnectionString =
                @"Data Source=42.112.28.93;Initial Catalog=QT_2;Persist Security Info=True;User ID=wss_price;Password=HzlRt4$$axzG-*UlpuL2gYDu;connection timeout=200";
            QT.Entities.Server.LogConnectionString =
                @"Data Source=172.22.30.86,1455;Initial Catalog=QT_2;Persist Security Info=True;User ID=qt_vn;Password=@F4sJ=l9/ryJt9MT;connection timeout=200";
            QT.Entities.Server.ConnectionStringCrawler =
                @"Data Source=172.22.30.82,1452;Initial Catalog=QTCrawler;Persist Security Info=True;User ID=qt_vn;Password=@F4sJ=l9/ryJt9MT;connection timeout=200";
            var rabbitMqServer = RabbitMQManager.GetRabbitMQServer("rabbitMQ177");

            for (var i = 0; i < pt.NumberThread; i++)
            {
                var token = CancellationTokenSource.Token;
                var j     = i;
                Task.Factory.StartNew(() =>
                {
                    var consumerFindNew = new ConsumerFindNew(rabbitMqServer, "CompanyWaitCrawlerFindNew", token);
                    consumerFindNew.Start();
                }, token);
            }
            while (true)
            {
                Console.Read();
            }
        }
コード例 #2
0
        public void ConsumerWorkerReloadTest()
        {
            var rabbitMqServer          = RabbitMQManager.GetRabbitMQServer(ConfigCrawler.KeyRabbitMqCrawler);
            var cancellationTokenSource = new CancellationTokenSource();
            var token = cancellationTokenSource.Token;

            Task.Factory.StartNew(() =>
            {
                consumerFindNew = new ConsumerFindNew(rabbitMqServer, "CompanyWaitCrawlerReload", token);
                consumerFindNew.Start();
            }, token);

            var countNumber = 0;

            while (true)
            {
                Thread.Sleep(60000);
                countNumber++;
                if (countNumber > 5)
                {
                    consumerFindNew.Stop();
                }
            }
        }