public IActionResult ManaualProcess(Guid messageId, string topic)
        {
            var message = MessageSvc.LoadMessage(messageId, topic);
            var msg     = new TextMessage()
            {
                MessageText = message.MessageText
            };

            msg.putHeaders(BuiltinKeys.TraceId, messageId.ToString());
            msg.putHeaders(BuiltinKeys.Topic, topic);
            Stopwatch stopwatch = new Stopwatch();
            IMonitor  monitor   = new SqlMonitor();

            try
            {
                var processor = new RestApiProcessor();
                stopwatch.Restart();
                var result = (processor.Process(msg)).Result;
                stopwatch.Stop();
                MessageSuccessEventArgs args = new MessageSuccessEventArgs(msg, stopwatch.ElapsedMilliseconds);
                monitor.onEvent(args);
                return(Json(new { Success = true, Message = "处理成功!" }));
            }
            catch (Exception ex)
            {
                stopwatch.Stop();
                MessageExceptionEventArgs args = new MessageExceptionEventArgs(msg, ex, stopwatch.ElapsedMilliseconds);
                monitor.onEvent(args);
            }
            return(Json(new { Success = true, Message = "处理失败!" }));
        }
        private void Consumer_Received(object sender, BasicDeliverEventArgs e)
        {
            var      body    = e.Body;
            var      msgStr  = Encoding.UTF8.GetString(body);
            IMessage message = JsonConvert.DeserializeObject <TextMessage>(msgStr);

            if (processor == null)
            {
                throw new MessageTransitException("Processor can not be null!");
            }
            try
            {
                stopwatch.Restart();
                bool result = (processor.Process(message)).Result;
                stopwatch.Stop();

                if (result)
                {
                    channel.BasicAck(e.DeliveryTag, false);
                    if (monitors != null && monitors.Count > 0)
                    {
                        MessageSuccessEventArgs args = new MessageSuccessEventArgs(message, stopwatch.ElapsedMilliseconds);
                        monitors.ForEach(m => m.onEvent(args));
                    }
                }
                else
                {
                    channel.BasicReject(e.DeliveryTag, false);
                    if (monitors != null && monitors.Count > 0)
                    {
                        MessageExceptionEventArgs args = new MessageExceptionEventArgs(message, new Exception("Proccess Failed!"), stopwatch.ElapsedMilliseconds);
                        monitors.ForEach(m => m.onEvent(args));
                    }
                }
            }
            catch (Exception ex)
            {
                stopwatch.Stop();
                channel.BasicReject(e.DeliveryTag, false);
                if (monitors != null && monitors.Count > 0)
                {
                    MessageExceptionEventArgs args = new MessageExceptionEventArgs(message, ex, stopwatch.ElapsedMilliseconds);
                    monitors.ForEach(m => m.onEvent(args));
                }
            }
        }
        public void onEvent(MessageEventArgs e)
        {
            if (e is MessageSuccessEventArgs)
            {
                MessageSuccessEventArgs args = e as MessageSuccessEventArgs;
                MessageSvc.UpdateMessageStatusToSuccess(Guid.Parse(args.message.Headers[BuiltinKeys.TraceId]), args.message.Headers[BuiltinKeys.Topic], args.milliseconds);
            }
            else if (e is MessageExceptionEventArgs)
            {
                MessageExceptionEventArgs args = e as MessageExceptionEventArgs;
                MessageSvc.UpdateMessageStatusToFail(new ProcessFailRecord()
                {
                    MessageId  = Guid.Parse(args.message.Headers[BuiltinKeys.TraceId]),
                    Topic      = args.message.Headers[BuiltinKeys.Topic],
                    FailRecord = args.ex.Message,
                    TimePeriod = args.milliseconds
                });

                #region 邮件通知


                #endregion
            }
        }