public async Task HandleReceivedMessage(string message, int retryCount, ulong deliveryTag) { Logger.LogLineWithLevel("OK", "HandleReceivedMessage: Processing message [{0}] started", deliveryTag); var success = await SendNotificationClient.SendNotification(this.Configuration, message); if (success) { this.QueueManager.Ack(deliveryTag); Logger.LogLineWithLevel("OK", "HandleReceivedMessage: Processing message [{0}] sucesfully", deliveryTag); } else if (retryCount < this.Configuration.RetryCount) { this.QueueManager.AddRetryMessage(message, retryCount + 1); this.QueueManager.Ack(deliveryTag); Logger.LogLineWithLevel("WARN", "HandleReceivedMessage: Processing message [{0}] failed - Sending to retry queue {1}/{2}", deliveryTag, retryCount + 1, this.Configuration.RetryCount); } else { this.QueueManager.AddDeadMessage(message); this.QueueManager.Ack(deliveryTag); Logger.LogLineWithLevel("WARN", "HandleReceivedMessage: Processing message [{0}] failed - Sending to dead queue", deliveryTag); } }
public async Task HandleReceivedMessage(string message, int retryCount, ulong deliveryTag) { Logger.LogLineWithLevel("OK", "HandleReceivedMessage: Processing message [{0}] started", deliveryTag); if (!string.IsNullOrWhiteSpace(this.Configuration.Condition)) { var(expression, isValid) = message.IsValid(this.Configuration.Condition); if (!isValid) { this.QueueManager.Ack(deliveryTag); Logger.LogLineWithLevel("OK", "HandleReceivedMessage: Message ignored [{0}]! {1}", deliveryTag, expression); return; } } var success = await SendNotificationClient.SendNotification(this.Configuration, message); if (success) { this.QueueManager.Ack(deliveryTag); Logger.LogLineWithLevel("OK", "HandleReceivedMessage: Processing message [{0}] sucesfully", deliveryTag); } else if (retryCount < this.Configuration.RetryCount) { this.QueueManager.AddRetryMessage(message, retryCount + 1); this.QueueManager.Ack(deliveryTag); Logger.LogLineWithLevel("WARN", "HandleReceivedMessage: Processing message [{0}] failed - Sending to retry queue {1}/{2}", deliveryTag, retryCount + 1, this.Configuration.RetryCount); } else { this.QueueManager.AddDeadMessage(message); this.QueueManager.Ack(deliveryTag); Logger.LogLineWithLevel("WARN", "HandleReceivedMessage: Processing message [{0}] failed - Sending to dead queue", deliveryTag); } }