Esempio n. 1
0
        public void SendResults()
        {
            CloudFoundryMongoBinder binder         = new CloudFoundryMongoBinder();
            MongoQueue <string>     collectorQueue = new MongoQueue <string>(binder.Url, binder.DatabaseName, "collector_queue", 32000);

            try
            {
                while (true)
                {
                    Console.WriteLine("Waiting for data...");

                    string userData = collectorQueue.Receive();

                    Console.WriteLine("Received " + userData);

                    Clients.Caller.addNewMessageToPage(userData);

                    Console.WriteLine("Data written");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception caught, ResultsCollector closing: " + e);
            }
        }
Esempio n. 2
0
        public static void Main()
        {
            Console.WriteLine("QueryWorkerApp starting...");

            CloudFoundryMongoBinder binder = new CloudFoundryMongoBinder();

            MongoQueue <string> collectorQueue = new MongoQueue <string>(binder.Url, binder.DatabaseName, "collector_queue", 32000);
            MongoQueue <string> workerQueue    = new MongoQueue <string>(binder.Url, binder.DatabaseName, "worker_queue", 32000);

            try
            {
                while (true)
                {
                    Console.WriteLine("Waiting...");

                    string result = workerQueue.Receive();

                    Console.WriteLine("Received " + result);

                    collectorQueue.Send(binder.AppPort + ":" + result.ToUpper());

                    Console.WriteLine("Back to top of loop");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Query worker exiting after exception: " + e);
            }
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            Console.WriteLine();
            Console.WriteLine("******* Collector starting ********");

            CloudFoundryMongoBinder binder         = new CloudFoundryMongoBinder();
            MongoQueue <string>     collectorQueue = new MongoQueue <string>(binder.Url, binder.DatabaseName, "collector_queue", 32000);

            server = new WebSocketServer();

            bool successfulSetup = server.Setup(Convert.ToInt32(binder.AppPort.Value));

            Console.WriteLine("Server setup complete");
            server.NewMessageReceived  += server_NewMessageReceived;
            server.NewSessionConnected += server_NewSessionConnected;
            bool successfulStart = server.Start();

            Console.WriteLine("Server started");

            while (true)
            {
                Console.WriteLine("Waiting for data...<");

                string userData = collectorQueue.Receive();

                Console.WriteLine(userData + "> writing to client...");

                SendToClient(userData);

                Console.WriteLine("data written");
            }
        }
Esempio n. 4
0
        static void PerformTimerOperation(Object stateInfo, ElapsedEventArgs args)
        {
            int workThreads = 0, completionThreads = 0;

            ThreadPool.GetAvailableThreads(out workThreads, out completionThreads);
            if (workThreads == 0)
            {
                return;
            }
            using (MongoQueue <TaskMessage> queue = new MongoQueue <TaskMessage>(ConfigurationManager.AppSettings["mongodbqueue"], 100000000))
            {
                var msg = queue.Receive();
                ThreadPool.QueueUserWorkItem(new WaitCallback(x =>
                {
                    if (msg != null)
                    {
                        logger.Info("initialize " + msg.ToString());
                        var task = TaskCreator.CreateInstance(msg);
                        task.Run();
                    }
                }));
            }
        }