private async Task <IEnumerable <object> > WrapAndRepublishRoutedMessages(IEnumerable <object> messages)
        {
            var wrappedMessages = messages
                                  .Where(message => !(message is IOutboundMessageInternal) &&
                                         !_inboundMessagesCache.Contains(message))
                                  .SelectMany(message =>
                                              _routing
                                              .GetRoutesForMessage(message)
                                              .Select(route =>
                                                      CreateOutboundMessage(message, route)));

            if (wrappedMessages.Any())
            {
                await _serviceProvider
                .GetRequiredService <IPublisher>()
                .PublishAsync(wrappedMessages);
            }

            return(wrappedMessages.Select(m => m.Content));
        }
        private async Task <IReadOnlyCollection <object> > WrapAndRepublishRoutedMessagesAsync(IEnumerable <object> messages)
        {
            var envelopesToRepublish = messages
                                       .Where(message => !(message is IOutboundEnvelope))
                                       .SelectMany(
                message =>
                _routing
                .GetRoutesForMessage(message)
                .SelectMany(
                    route =>
                    CreateOutboundEnvelope(message, route)))
                                       .ToList();

            if (envelopesToRepublish.Any())
            {
                await _serviceProvider
                .GetRequiredService <IPublisher>()
                .PublishAsync(envelopesToRepublish)
                .ConfigureAwait(false);
            }

            return(envelopesToRepublish.Select(m => m.Message).ToList() !);
        }