예제 #1
0
        public void Run()
        {
            LogManager.Log.Info("WorkerRole.Run Loop Started");

            using (IOutgoingSmsQueue outgoing = OutgoingSmsQueue.GetInstance())
            {
                outgoing.Send(OutgoingSmsMessage.CreateWithDefaults(_Configuration.AdminNumber,
                                                                    "WorkerRole.Run Loop Started"),
                              null,
                              null);

                while (true)
                {
                    // waiting for the queue to drain ensures we won't pick up the same one twice
                    if (outgoing.Length == 0)
                    {
                        IDataStore store = DataStore.GetInstance();

                        ProcessOutgoingMessages(outgoing, store);
                        ProcessSubscriptions(outgoing, store);
                    }
                    else
                    {
                        // there is already a back-log do don't go adding more to it...
                        Thread.Sleep(5 * 1000);
                    }
                }
            }
        }
예제 #2
0
        public override bool OnStart()
        {
            // Set the maximum number of concurrent connections
            ServicePointManager.DefaultConnectionLimit = 12;

            try
            {
                CreateServiceHost();
                LogManager.Log.Info("WCF Services started");
            }
            catch (Exception ex)
            {
                LogManager.Log.Error("Exception configuring WCF Services", ex);

                using (IOutgoingSmsQueue outgoing = OutgoingSmsQueue.GetInstance())
                {
                    IConfiguration config = Configuration.GetInstance();
                    outgoing.Send(OutgoingSmsMessage.CreateWithDefaults(config.AdminNumber,
                                                                        "WCF STARTUP ERROR: " + ex.GetType().FullName),
                                  null,
                                  null);
                }
            }

            return(base.OnStart());
        }