Exemple #1
0
 /// <summary>
 /// 初始化相关业务对象
 /// </summary>
 private void Setup()
 {
     try
     {
         m_objQueue = MsmqHelper.GetQueue(s_strMsmqPath);
         if (null == m_objQueue)
         {
             m_isInitMsmqSuccessed = false;
             Logger.Error("队列不存在 - " + s_strMsmqPath, new ApplicationException("队列不存在 - " + s_strMsmqPath));
         }
         else
         {
             m_isInitMsmqSuccessed = true;
             m_objQueue.Formatter  = new XmlMessageFormatter(new string[] { "JinRi.Notify.Frame.LogMessage, JinRi.Notify.Frame" });
             m_objMsmqObserver     = new MsmqObserver(m_objQueue, new WaitCallback(NotifyMe));
         }
         m_objRealLogger = LoggerFactory.CreateLogger();
         m_handlePool    = new DataBufferPool(new WaitCallback(LogHandleBatchMessage));
         m_processPool   = new DataBufferPool(new WaitCallback(LogProcessBatchMessage));
     }
     catch (Exception ex)
     {
         Logger.Error("获取队列时产生异常 - " + s_strMsmqPath, ex);
     }
 }
Exemple #2
0
        public ReceiveMessageBusiness()
        {
            if (ReceiveServiceSetting.IsOpenBatchReceiveHighMessage)
            {
                _highPool = new DataBufferPool(BatchHighPublisher, ReceiveServiceSetting.AutoFlushReceiveHighMessage, false);
            }
            if (ReceiveServiceSetting.IsOpenBatchReceiveMiddleMessage)
            {
                _middlePool = new DataBufferPool(BatchMiddlePublisher, ReceiveServiceSetting.AutoFlushReceiveMiddleMessage, false);
            }
            if (ReceiveServiceSetting.IsOpenBatchReceiveNormalMessage)
            {
                _normalPool = new DataBufferPool(BatchNormalPublisher, ReceiveServiceSetting.AutoFlushReceiveNormalMessage, false);
            }
            if (ReceiveServiceSetting.IsOpenBatchReceiveLowMessage)
            {
                _lowPool = new DataBufferPool(BatchLowPublisher, ReceiveServiceSetting.AutoFlushReceiveLowMessage, false);
            }
            Array enumArr = Enum.GetValues(typeof(MessagePriorityEnum));

            foreach (MessagePriorityEnum e in enumArr)
            {
                if (e != MessagePriorityEnum.None)
                {
                    RabbitMQBus bus = new RabbitMQBus();
                    m_rabbitBusDic.Add(e, bus);
                }
            }
        }
 private void DirectSavePushMessage(List <PushMessageModel> messageList)
 {
     ThreadPool.QueueUserWorkItem(x =>
     {
         bool ret     = false;
         object[] arr = (object[])x;
         List <PushMessageModel> list = (List <PushMessageModel>)arr[0];
         IDataBufferPool pool         = (IDataBufferPool)arr[1];
         object lockObj = arr[2];
         Dictionary <string, int> repeatSaveTimes = (Dictionary <string, int>)arr[3];
         try
         {
             ret = _pushMessageBus.Save(list);
             Process.Debug("保存消息通知", "_pushMessageBus.Save", string.Format("结果:【{0}】,条数:【{1}】", ret, list.Count), "");
         }
         catch (Exception ex)
         {
             Process.Error("保存消息通知", "_pushMessageBus.Save", string.Format("结果:【{0}】,条数:【{1}】,异常:【{2}】", ret, list.Count, ex.GetString()), "");
         }
         if (!ret)
         {
             list.ForEach(a => {
                 _repeatSavePool.Write(a);
                 lock (m_repeatSaveTimesLockObj)
                 {
                     m_repeatSaveTimes[a.MessageId] = 1;
                 }
             });
         }
     }, new object[] { messageList, _repeatSavePool, m_repeatSaveTimesLockObj, m_repeatSaveTimes });
 }
 public BuildMessageBusiness()
 {
     _notifyMessageBus = new NotifyMessageBusiness();
     _pushMessageBus   = new PushMessageBusiness(BuilderServiceSetting.AutoFlushSendMessage);
     _notifySettingBus = new NotifyInterfaceSettingBusiness();
     if (BuilderServiceSetting.IsOpenBatchSaveNotifyMessage)
     {
         _saveNotifyPool = new DataBufferPool(new WaitCallback(BatchSaveNotifyMessage), BuilderServiceSetting.AutoFlushNotifyMessage, false);
     }
     if (BuilderServiceSetting.IsOpenBatchSavePushMessage)
     {
         _savePushPool = new DataBufferPool(new WaitCallback(BatchSavePushMessage), BuilderServiceSetting.AutoFlushPushMessage, false);
     }
     if (BuilderServiceSetting.IsOpenBatchReceiveHighMessage)
     {
         _highPool = new DataBufferPool(new WaitCallback(BuildBufferMessage), BuilderServiceSetting.AutoFlushReceiveHighMessage, false);
     }
     if (BuilderServiceSetting.IsOpenBatchReceiveMiddleMessage)
     {
         _middlePool = new DataBufferPool(new WaitCallback(BuildBufferMessage), BuilderServiceSetting.AutoFlushReceiveMiddleMessage, false);
     }
     if (BuilderServiceSetting.IsOpenBatchReceiveNormalMessage)
     {
         _normalPool = new DataBufferPool(new WaitCallback(BuildBufferMessage), BuilderServiceSetting.AutoFlushReceiveNormalMessage, false);
     }
     if (BuilderServiceSetting.IsOpenBatchReceiveLowMessage)
     {
         _lowPool = new DataBufferPool(new WaitCallback(BuildBufferMessage), BuilderServiceSetting.AutoFlushReceiveLowMessage, false);
     }
     _repeatSavePool = new DataBufferPool(new WaitCallback(RepeatSaveMessage), 5, false);
 }
Exemple #5
0
        public LogMessageDAL()
        {
            _repeatBatchSaveHandlePool  = new DataBufferPool(new WaitCallback(RepeatBatchSaveHandleLog), 10, false);
            _repeatBatchSaveProcessPool = new DataBufferPool(new WaitCallback(RepeatBatchSaveProcessLog), 12, false);
#if APPSERVER
            _repeatRescovryDataPool = new DataBufferPool(new WaitCallback(RepeatRescovryLog), 60, false);
            _repeatRescovryDataPool.Write(1);
#endif
        }
        private LogMessageDAL()
        {
            _repeatBatchSaveHandlePool = new DataBufferPool(20, 5, TimeSpan.FromSeconds(120));
            _repeatBatchSaveHandlePool.OnDataHandle += OnSendRequest;
            _repeatBatchSaveHandlePool.TimerFlushAsync();

            _repeatBatchSaveProcessPool = new DataBufferPool(20, 5, TimeSpan.FromSeconds(120), false);
            _repeatBatchSaveProcessPool.OnDataHandle += OnSendRequest;
            _repeatBatchSaveProcessPool.TimerFlushAsync();
        }
Exemple #7
0
 public SendMessageBusiness()
 {
     _pushMessageBus = new PushMessageBusiness();
     _pushSettingBus = new NotifyInterfaceSettingBusiness();
     if (SendServiceSetting.IsOpenBatchSendHighMessage)
     {
         _highPool = new DataBufferPool(new WaitCallback(SendBatch), SendServiceSetting.AutoFlushSendHighMessage, false);
     }
     if (SendServiceSetting.IsOpenBatchSendMiddleMessage)
     {
         _middlePool = new DataBufferPool(new WaitCallback(SendBatch), SendServiceSetting.AutoFlushSendMiddleMessage, false);
     }
     if (SendServiceSetting.IsOpenBatchSendNormalMessage)
     {
         _normalPool = new DataBufferPool(new WaitCallback(SendBatch), SendServiceSetting.AutoFlushSendNormalMessage, false);
     }
     if (SendServiceSetting.IsOpenBatchSendLowMessage)
     {
         _lowPool = new DataBufferPool(new WaitCallback(SendBatch), SendServiceSetting.AutoFlushSendLowMessage, false);
     }
     _repeatUpdatePool = new DataBufferPool(new WaitCallback(RepeatUpdatePushMessage), 10, false);
 }
Exemple #8
0
        static DBLog()
        {
            try
            {
                m_localLog = LoggerSource.Instance.GetLogger(typeof(DBLog));

                AppSetting.InitDistributionConfig();
                m_logToServer   = AppSetting.LogToServer;
                m_localServer   = ServerManager.GetLocalServer();
                m_localServerIP = IPHelper.GetLocalIP();

                m_localServerCode = m_localServer != null ? m_localServer.ServerCode : m_localServerIP;
                if (m_openLogCenter)
                {
#if THRIFT
                    ZKManager.Client.Init();
                    InitThriftServer();
#endif
                }

                m_request = RegisterService.TaskRequestService.GetService(m_logToServer);

                m_logHandlePool = new DataBufferPool(BatchSendHandleRequest)
                {
                    AutoFlushLogSeconds = 5,
                    IsBlockMainThread   = false
                };
                m_logProcessPool = new DataBufferPool(BatchSendProcessRequest)
                {
                    AutoFlushLogSeconds = 3,
                    IsBlockMainThread   = false
                };
            }
            catch (Exception ex)
            {
                m_localLog.Error(ex);
            }
        }
Exemple #9
0
        static DBLog()
        {
            try
            {
                s_localServerIP = IPHelper.GetLocalIP();

                s_logHandlePool = new DataBufferPool(AppSetting.DataBufferPoolSize, AppSetting.DataBufferSize,
                                                     TimeSpan.FromSeconds(AppSetting.AutoFlushSecond));
                s_logHandlePool.OnDataHandle += OnSendRequest;
                s_logHandlePool.TimerFlushAsync();

                s_logProcessPool = new DataBufferPool(AppSetting.DataBufferPoolSize, AppSetting.DataBufferSize,
                                                      TimeSpan.FromSeconds(AppSetting.AutoFlushSecond), false);
                s_logProcessPool.OnDataHandle += OnSendRequest;
                s_logProcessPool.TimerFlushAsync();

                m_localLog.Info("初始化DataBufferPool成功");
            }
            catch (Exception ex)
            {
                m_localLog.Error(ex);
            }
        }
 public PushMessageBusiness(int sendMessagePool)
 {
     _sendMessagePool = new DataBufferPool(new WaitCallback(BatchSendMessage), sendMessagePool, false);
 }
 public ScanMessageBusiness()
 {
     _repeatNotifyPool = new DataBufferPool(RepeatNotifyOrder, 5, false);
 }