Exemplo n.º 1
0
        async Task SendToSite(byte[] body, Dictionary <string, string> headers, Site targetSite, SingleCallChannelForwarder forwarder)
        {
            headers[Headers.OriginatingSite] = GetDefaultAddressForThisSite();

            await forwarder.Forward(body, headers, targetSite).ConfigureAwait(false);

            messageNotifier.RaiseMessageForwarded(localAddress, targetSite.Channel.Type, body, headers);
        }
Exemplo n.º 2
0
        public async Task SendToDestination(MessageContext context, IDispatchMessages dispatcher, SingleCallChannelForwarder forwarder)
        {
            var intent = GetMessageIntent(context.Headers);

            var destinationSites = GetDestinationSitesFor(context.Headers, intent);

            //if there is more than 1 destination we break it up into multiple dispatches
            if (destinationSites.Count > 1)
            {
                foreach (var destinationSite in destinationSites)
                {
                    await CloneAndSendLocal(context.Body, context.Headers, destinationSite, context.TransportTransaction, dispatcher).ConfigureAwait(false);
                }

                return;
            }

            var destination = destinationSites.FirstOrDefault();

            if (destination == null)
            {
                throw new InvalidOperationException("No destination found for message");
            }

            await SendToSite(context.Body, context.Headers, destination, forwarder).ConfigureAwait(false);
        }