コード例 #1
0
 void Subscribe(Notifications notifications)
 {
     var errorsNotifications = notifications.Errors;
     errorsNotifications.MessageHasBeenSentToSecondLevelRetries += (sender, retry) => LogEvent(retry);
     errorsNotifications.MessageHasFailedAFirstLevelRetryAttempt += (sender, retry) => LogEvent(retry);
     errorsNotifications.MessageSentToErrorQueue += (sender, retry) => LogEvent(retry);
 }
コード例 #2
0
        EventsToObservables(Notifications notifications, ILog log)
        {
            #region ConvertEventToObservable

            IObservable<EventPattern<FailedMessage>> failedMessages = Observable.FromEventPattern<EventHandler<FailedMessage>, FailedMessage>(
                handler => notifications.Errors.MessageSentToErrorQueue += handler,
                handler => notifications.Errors.MessageSentToErrorQueue -= handler);

            IDisposable subscription = failedMessages
                .Subscribe(x =>
                {
                    FailedMessage failedMessage = x.EventArgs;
                    log.Error($"Message {failedMessage.MessageId} moved to error queue", failedMessage.Exception);
                });

            #endregion
        }