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()); } }
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); }
public Task NotifyAsync(INotification notification) { Require.NotNull(notification, "notification"); return(m_channel.SendAsync(notification)); }