Beispiel #1
0
 private void SaveFailMqMeessage(int count)
 {
     FailMqMessageModel[] array = new FailMqMessageModel[FailMqMessageModels.Count >= count ? count : FailMqMessageModels.Count];
     if (FailMqMessageModels.Count > 0)
     {
         FailMqMessageModels.TryPopRange(array, 0, array.Length);
     }
     if (array.Length > 0)
     {
         new DataCenterHelper().WriteToList(array);
     }
 }
Beispiel #2
0
        internal void Handler(FailMqMessageModel model)
        {
            int count = 1;
            var flag  = false;

            do
            {
                int defaultInterval     = 1000;
                TaskBaseResponse result = null;
                try
                {
                    result = HttpHelper.HttpPost <TaskBaseResponse>(model.ApiUrl, model.MessageContext);
                    LogHelper.LogInfo(logSource, string.Format("MqMessageExecute 调用业务API: {0};{1};{2}", model.ApiUrl, model.MessageContext, result.ToJsonString()));
                }
                catch (Exception ex)
                {
                    if (result.IsNull())
                    {
                        result = new TaskBaseResponse()
                        {
                            Status = System.Net.HttpStatusCode.InternalServerError
                        };
                    }
                    defaultInterval += 500;
                    LogHelper.LogError(logSource, string.Format("MqMessageExecute 调用业务异常API: {0};{1};{2}; ex:{3}", model.ApiUrl, model.MessageContext, result.ToJsonString(), ex.ToString()));
                }
                if (result.Status == System.Net.HttpStatusCode.OK)
                {
                    flag = UpdateStatus(model.Code, FailMqMessageStatus.Success);
                    break;
                }
                else
                {
                    count++;
                    Thread.CurrentThread.Join(defaultInterval * count);
                }
            } while (count <= 5);
            if (!flag)
            {
                UpdateStatus(model.Code, FailMqMessageStatus.HandlerFail, count);
            }
        }