Beispiel #1
0
        private async Task ProcessMessageAsync(
            OutboxStoredMessage message,
            IOutboxReader outboxReader,
            IServiceProvider serviceProvider)
        {
            try
            {
                var endpoint = GetTargetEndpoint(message.MessageType, message.EndpointName, serviceProvider);
                await ProduceMessageAsync(message.Content, message.Headers, endpoint).ConfigureAwait(false);

                await outboxReader.AcknowledgeAsync(message).ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                _logger.LogErrorWithMessageInfo(
                    IntegrationEventIds.ErrorProducingOutboxStoredMessage,
                    ex,
                    "Failed to produce the message in the outbox.",
                    new OutboundEnvelope(message.Content, message.Headers, new LoggingEndpoint(message.EndpointName)));

                await outboxReader.RetryAsync(message).ConfigureAwait(false);

                // Rethrow if message order has to be preserved, otherwise go ahead with next message in the queue
                if (_enforceMessageOrder)
                {
                    throw;
                }
            }
        }
Beispiel #2
0
        private static async Task AcknowledgeAllAsync(
            IOutboxReader outboxReader,
            List <OutboxStoredMessage> messages,
            ConcurrentBag <OutboxStoredMessage> failedMessages)
        {
            await outboxReader.RetryAsync(failedMessages).ConfigureAwait(false);

            await outboxReader.AcknowledgeAsync(messages.Where(message => !failedMessages.Contains(message)))
            .ConfigureAwait(false);
        }