Пример #1
0
        public void Worker()
        {
            if (Config.CoreTest != 0)
            {
                Logger.Log.Warn("Running in CoreTest mode ({0})", Config.CoreTest);
            }

            SendCounter.Refresh();
            ErrorCounter.Refresh();
            LastSendCount  = 0;
            LastErrorCount = 0;

            var timer = new Timer(GetStatus, null, 0, Config.NotifyPeriod * 1000);

            do
            {
                ProcessMassMail();
                Thread.Sleep(2000);

                //Trigger GC to reduce LOH fragmentation
                GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce;
                GC.Collect();
            }while (!_threadStop);

            timer.Dispose();
        }
Пример #2
0
        /// <summary>
        /// Получает текущее значение счетчика отправленных писем
        /// </summary>
        private void GetStatus(object sender)
        {
            var curSendCount  = SendCounter.Read();
            var curErrorCount = ErrorCounter.Read();

            //If massMail object was recreated
            LastSendCount  = (curSendCount < LastSendCount) ? 0 : LastSendCount;
            LastErrorCount = (curErrorCount < LastErrorCount) ? 0 : LastErrorCount;
            Zabbix.Sender.SendData(new ZabbixItem {
                Host = Config.HostKey, Key = Config.SendCountKey, Value = (curSendCount - LastSendCount).ToString(CultureInfo.InvariantCulture)
            });
            Zabbix.Sender.SendData(new ZabbixItem {
                Host = Config.HostKey, Key = Config.ErrorCountKey, Value = (curErrorCount - LastErrorCount).ToString(CultureInfo.InvariantCulture)
            });
            Logger.Log.Debug("Send to zabbix - send: {0}, errors: {1}", curSendCount - LastSendCount, curErrorCount - LastErrorCount);
            Logger.Log.Debug("Total - send: {0}, errors: {1}", curSendCount, curErrorCount);
            LastSendCount  = curSendCount;
            LastErrorCount = curErrorCount;
        }
Пример #3
0
 /// <summary>
 /// Обработчик события об отправленных сообщениях
 /// </summary>
 public void OnMessagesSend(long sendCount, long errorCount)
 {
     SendCounter.Add(sendCount);
     ErrorCounter.Add(errorCount);
     Logger.Log.Debug("Messages processed - send: {0} + errors: {1}", SendCounter.Read(), ErrorCounter.Read());
 }