public async Task CleanMessages(bool ignoreAndLogExceptions = true) { var threshold = Configuration.GetCleanOutboxMessagesTimeThreshold(); Logger.LogInformation($"Cleaning outbox of outgoing messages with ids older then: {threshold.ToString()}."); var outboxMessages = await OutboxMessageRepository.SelectOutboxMessagesBeforeThreshold(threshold); foreach (var outboxMessage in outboxMessages) { try { await Bus.ResendOutboxMessage(outboxMessage); await OutboxMessageRepository.DeleteOutboxMessage(outboxMessage.Id); } catch (Exception e) { Logger.LogError($"Could not resend outbox message with id: {outboxMessage.Id}. \r\nFollowing error occured: {e.Message}"); if (!ignoreAndLogExceptions) { throw; } } } }
public async Task Commit() { foreach (var tuple in FuncsToCommit) { await tuple.Item1.Invoke(); await OutboxMessageRepository.DeleteOutboxMessage(tuple.Item2); } FuncsToCommit = null; }