示例#1
0
        private async Task <Envelope> sendEnvelope(Envelope envelope, MessageRoute route, IMessageCallback callback)
        {
            if (route == null)
            {
                throw new ArgumentNullException(nameof(route));
            }

            ITransport transport = null;

            if (_transports.TryGetValue(route.Destination.Scheme, out transport))
            {
                var sending = route.CloneForSending(envelope);

                var channel = _channels.TryGetChannel(route.Destination);

                if (channel != null)
                {
                    await sendToStaticChannel(callback, sending, channel);
                }
                else
                {
                    await sendToDynamicChannel(route.Destination, callback, sending, transport);
                }

                Logger.Sent(sending);

                return(sending);
            }
            else
            {
                throw new InvalidOperationException($"Unrecognized transport scheme '{route.Destination.Scheme}'");
            }
        }