コード例 #1
0
        internal bool UpdateStatus(string code, FailMqMessageStatus status, int count = 0)
        {
            DataCenterHelper dataCenter = new DataCenterHelper();
            var paramList = new List <SqlParameter> {
                new SqlParameter()
                {
                    ParameterName = "@status", Value = (int)status, SqlDbType = System.Data.SqlDbType.Int
                },
                new SqlParameter()
                {
                    ParameterName = "@code", Value = code, SqlDbType = System.Data.SqlDbType.VarChar, Size = 36
                },
            };

            if (count == 0)
            {
                return(dataCenter.ExecuteNonQuery("UPDATE FailMqMessage SET STATUS=@status,UpdateTime=GetDate() WHERE Code = @code", paramList.ToArray()));
            }
            else
            {
                paramList.Add(new SqlParameter()
                {
                    ParameterName = "@RetryNumber", Value = count, SqlDbType = System.Data.SqlDbType.Int
                });
                return(dataCenter.ExecuteNonQuery("UPDATE FailMqMessage SET STATUS=@status,UpdateTime=GetDate(),RetryNumber=RetryNumber+@RetryNumber WHERE Code = @code", paramList.ToArray()));
            }
        }
コード例 #2
0
        /// <summary>
        /// 重置处理中的状态为待处理
        /// </summary>
        public void ResetStatus()
        {
            DataCenterHelper dataCenter = new DataCenterHelper();
            var paramList = new List <SqlParameter> {
                new SqlParameter()
                {
                    ParameterName = "@status", Value = 0, SqlDbType = System.Data.SqlDbType.Int
                },
                new SqlParameter()
                {
                    ParameterName = "@status1", Value = 1, SqlDbType = System.Data.SqlDbType.Int
                },
            };

            dataCenter.ExecuteNonQuery("UPDATE FailMqMessage SET STATUS=@status,UpdateTime=GetDate() WHERE STATUS=@status1", paramList.ToArray());
        }
コード例 #3
0
        /// <summary>
        /// 运行一次MQ错误消息处理业务
        /// </summary>
        /// <returns></returns>
        public bool Run()
        {
            bool             isNext     = false;
            DataCenterHelper dataCenter = new DataCenterHelper();
            var failMessages            = dataCenter.GetFailMqMessageModels(total, FailMqMessageStatus.Wait);

            if (failMessages != null && failMessages.Count > 0)
            {
                foreach (var item in failMessages)
                {
                    UpdateStatus(item.Code, FailMqMessageStatus.Handlering);
                    ThreadPool.QueueUserWorkItem((obj) =>
                    {
                        Handler((FailMqMessageModel)obj);
                    }, item);
                }
                isNext = total == failMessages.Count;
            }
            else
            {
                LogHelper.LogWarn(logSource, "没有待处理状态的FailMqMessage数据");
            }
            return(isNext);
        }