Exemplo n.º 1
0
        private static string CreateMessage(FailContext context)
        {
            var msg = "";

            if (context.Raw != null)
            {
                msg = $"您订阅的消息{context.Raw}处理失败,失败原因{context.ExceptionMessage}";
            }

            if (context.State is ReceivedMessage receivedMessage)
            {
                msg = $"您订阅的消息处理失败,Id={receivedMessage.Id},TransactId={receivedMessage.TransactId},Group={receivedMessage.Group},Topic={receivedMessage.RouteKey},失败原因:{context.ExceptionMessage}";
            }

            return(msg);
        }
Exemplo n.º 2
0
 private static void HandleError(IServiceProvider serviceProvider, FailContext context)
 {
     ThreadPool.QueueUserWorkItem((state) =>
     {
         try
         {
             var handlers = serviceProvider.GetServices <ISubFailureHandler>();
             foreach (var handler in handlers)
             {
                 handler.HandleAsync(context);
             }
         }
         catch
         {
             // ignored
         }
     });
 }
Exemplo n.º 3
0
        public async Task HandleAsync(FailContext context)
        {
            if (!_options.Enable)
            {
                return;
            }

            if (!_options.Contacts.Any())
            {
                return;
            }

            var now = DateTime.Now;

            if ((now - _memento.LastPubAlert).TotalSeconds < _options.AlertIntervalSecs)
            {
                return;
            }

            _memento.LastPubAlert = now;

            var request = new FeiniuBusSDK.Notification.Model.CreateSmsRequest
            {
                Numbers = _options.Contacts,
                Message = CreateMessage(context)
            };

            try
            {
                await _feiniuBusNotification.CreateSmsAsync(request);
            }
            catch (Exception ex)
            {
                _logger.LogError(110, ex, $"订阅消息失败通知发送失败");
            }
        }
Exemplo n.º 4
0
 public FailRepository(FailContext failContext)
 {
     this.failContext = failContext;
 }