public MessageInformations ApplyRetryStrategy(Channel channel, T deliveredMessage) { if (String.IsNullOrEmpty(deliveredMessage.DeliveryTag)) { throw new ArgumentNullException(nameof(deliveredMessage.DeliveryTag)); } if (!RetryInformations.ContainsKey(deliveredMessage.DeliveryTag)) { throw new MerqureToolsException($"unknown delivery tag {deliveredMessage.DeliveryTag}"); } RetryInformations retryInformations = RetryInformations[deliveredMessage.DeliveryTag]; var messageInformations = new MessageInformations(); if (IsGoingToErrorExchange(retryInformations)) { _producer.PublishOnErrorExchange(channel, deliveredMessage, retryInformations); messageInformations.IsOnErrorBus = true; } else { _producer.PublishOnRetryExchange(channel, deliveredMessage, retryInformations); } AcknowlegdeDeliveredMessage(channel, deliveredMessage); RetryInformations.Remove(deliveredMessage.DeliveryTag); return(messageInformations); }
public MessageInformations ForceRetryStrategy(Channel channel, T message, int attemptNumber) { var retryInformations = new RetryInformations() { NumberOfRetry = attemptNumber > 0 ? attemptNumber - 1 : 0 }; var messageInformations = new MessageInformations(); if (IsGoingToErrorExchange(retryInformations)) { _producer.PublishOnErrorExchange(channel, message, retryInformations); messageInformations.IsOnErrorBus = true; } else { _producer.PublishOnRetryExchange(channel, message, retryInformations); } return(messageInformations); }