コード例 #1
0
        public async Task RetryNotificationProcessingAsync(INotification notification)
        {
            Require.NotNull(notification, "notification");

            if (notification.DeliveryCount < Constants.Settings.MAX_NOTIFICATION_PROCESSING_ATTEMPT_COUNT)
            {
                var retryNotification = notification.SendTo(m_listener);
                var deliverTimeout    = TimeSpan.FromSeconds(
                    notification.DeliveryCount * Constants.Settings.NOTIFICATION_RETRY_DELIVERY_TIMEOUT_MULTIPLYER_SEC);

                if (s_logger.IsEnabled(LogEventLevel.Debug))
                {
                    s_logger.Debug(
                        "Sending retry notification ({RetryNotificationId}, {NotificationType}) with timeout {Timeout} " +
                        "to consumer {ListenerType}. " +
                        "Source notification: {SourceNotificationId}.",
                        retryNotification.NotificationId,
                        retryNotification.NotificationType,
                        deliverTimeout.ToInvariantString(),
                        GetConsumerId(),
                        notification.NotificationId);
                }

                await m_notificationsChannel.SendAsync(retryNotification, deliverTimeout);
            }
            else
            {
                s_logger.Error(
                    "Number of processing attempt has been exceeded. " +
                    "Listener type: {ListenerType}. " +
                    "NotificationId: {Notification}. " +
                    "NotificationType: {NotificationType}. " +
                    "Delivery count: {DeliveryCount}. " +
                    "Maximum deliver count: {MaxDeliveryCount}",
                    m_listener.GetType(),
                    notification.NotificationId,
                    notification.NotificationType,
                    notification.DeliveryCount.ToInvariantString(),
                    Constants.Settings.MAX_NOTIFICATION_PROCESSING_ATTEMPT_COUNT.ToInvariantString());
            }
        }
コード例 #2
0
        public async Task ChannelReceivesAllSendedNotifications()
        {
            var notifications = m_fixture.CreateMany <EventStreamUpdated>().ToList();

            foreach (var notification in notifications)
            {
                await m_channel.SendAsync(notification);
            }

            var receivedNotification = new List <INotification>();

            foreach (var _ in Enumerable.Range(0, notifications.Count()))
            {
                foreach (var notification in await m_channel.ReceiveNotificationsAsync())
                {
                    receivedNotification.Add(notification.Notification);
                    await notification.CompleteAsync();
                }
            }

            Assert.Equal(notifications.Count(), receivedNotification.Count);
        }
コード例 #3
0
        public Task NotifyAsync(INotification notification)
        {
            Require.NotNull(notification, "notification");

            return(m_channel.SendAsync(notification));
        }