private Task InvokeTransport(OutgoingTransportContext context)
        {
            if (this.executingTransportPipeline.Count == 0)
            {
                return(Task.FromResult(0));
            }

            IOutgoingTransportStep step = this.executingTransportPipeline.Dequeue();

            return(step.Invoke(context, () => this.InvokeTransport(context)));
        }
        public async Task Invoke(OutgoingTransportContext context, Func<Task> next)
        {
            using (var ms = new MemoryStream())
            {
                this.serializer.Serialize(context.LogicalMessage.Instance, ms);

                context.OutgoingTransportMessage.ContentType = this.serializer.ContentType;
                context.OutgoingTransportMessage.MessageType = context.LogicalMessage.Instance.GetType().AssemblyQualifiedName;

                context.OutgoingTransportMessage.SetBody(ms);

                await next()
                    .ConfigureAwait(false);
            }
        }
        public async Task Invoke(OutgoingTransportContext context, Func <Task> next)
        {
            using (var ms = new MemoryStream())
            {
                this.serializer.Serialize(context.LogicalMessage.Instance, ms);

                context.OutgoingTransportMessage.ContentType = this.serializer.ContentType;
                context.OutgoingTransportMessage.MessageType = context.LogicalMessage.Instance.GetType().AssemblyQualifiedName;

                context.OutgoingTransportMessage.SetBody(ms);

                await next()
                .ConfigureAwait(false);
            }
        }
        public virtual async Task Invoke(LogicalMessage outgoingLogicalMessage, DeliveryOptions options, EndpointConfiguration.ReadOnly configuration, TransportMessage incomingTransportMessage = null)
        {
            this.executingLogicalPipeline = new Queue <IOutgoingLogicalStep>(this.registeredlogicalPipelineSteps);
            var logicalContext = new OutgoingLogicalContext(outgoingLogicalMessage, options, configuration);

            logicalContext.SetChain(this);
            await this.InvokeLogical(logicalContext)
            .ConfigureAwait(false);

            // We assume that someone in the pipeline made transport message
            var outgoingTransportMessage = logicalContext.Get <TransportMessage>();

            this.executingTransportPipeline = new Queue <IOutgoingTransportStep>(this.registeredTransportPipelineSteps);
            var transportContext = new OutgoingTransportContext(outgoingLogicalMessage, outgoingTransportMessage, options, configuration, incomingTransportMessage);

            transportContext.SetChain(this);
            await this.InvokeTransport(transportContext)
            .ConfigureAwait(false);
        }
        public Task Invoke(OutgoingTransportContext context, Func<Task> next)
        {
            var sendOptions = context.Options as SendOptions;
            if (ShouldDetermineSendDestination(sendOptions))
            {
// ReSharper disable PossibleNullReferenceException
                sendOptions.Queue = this.GetDestinationForSend(context.LogicalMessage.Instance);
// ReSharper restore PossibleNullReferenceException
            }

            var publishOptions = context.Options as PublishOptions;
            if (ShouldDeterminePublishDestination(publishOptions))
            {
// ReSharper disable PossibleNullReferenceException
                publishOptions.Topic = this.GetDestinationForPublish(context.LogicalMessage.Instance);
// ReSharper restore PossibleNullReferenceException
            }

            return next();
        }
        public async Task Invoke(OutgoingTransportContext context, Func <Task> next)
        {
            var sendOptions = context.Options as SendOptions;

            if (sendOptions != null)
            {
                await this.sender.SendAsync(context.OutgoingTransportMessage, sendOptions)
                .ConfigureAwait(false);
            }

            var publishOptions = context.Options as PublishOptions;

            if (publishOptions != null)
            {
                await this.publisher.PublishAsync(context.OutgoingTransportMessage, publishOptions)
                .ConfigureAwait(false);
            }

            await next()
            .ConfigureAwait(false);
        }
        public Task Invoke(OutgoingTransportContext context, Func <Task> next)
        {
            var sendOptions = context.Options as SendOptions;

            if (ShouldDetermineSendDestination(sendOptions))
            {
// ReSharper disable PossibleNullReferenceException
                sendOptions.Queue = this.GetDestinationForSend(context.LogicalMessage.Instance);
// ReSharper restore PossibleNullReferenceException
            }

            var publishOptions = context.Options as PublishOptions;

            if (ShouldDeterminePublishDestination(publishOptions))
            {
// ReSharper disable PossibleNullReferenceException
                publishOptions.Topic = this.GetDestinationForPublish(context.LogicalMessage.Instance);
// ReSharper restore PossibleNullReferenceException
            }

            return(next());
        }
            public Task Invoke(OutgoingTransportContext context, Func <Task> next)
            {
                var step = this.factory();

                return(step.Invoke(context, next));
            }
Esempio n. 9
0
        public virtual async Task Invoke(LogicalMessage outgoingLogicalMessage, DeliveryOptions options, EndpointConfiguration.ReadOnly configuration, TransportMessage incomingTransportMessage = null)
        {
            this.executingLogicalPipeline = new Queue<IOutgoingLogicalStep>(this.registeredlogicalPipelineSteps);
            var logicalContext = new OutgoingLogicalContext(outgoingLogicalMessage, options, configuration);
            logicalContext.SetChain(this);
            await this.InvokeLogical(logicalContext)
                .ConfigureAwait(false);

            // We assume that someone in the pipeline made transport message
            var outgoingTransportMessage = logicalContext.Get<TransportMessage>();

            this.executingTransportPipeline = new Queue<IOutgoingTransportStep>(this.registeredTransportPipelineSteps);
            var transportContext = new OutgoingTransportContext(outgoingLogicalMessage, outgoingTransportMessage, options, configuration, incomingTransportMessage);
            transportContext.SetChain(this);
            await this.InvokeTransport(transportContext)
                .ConfigureAwait(false);
        }
Esempio n. 10
0
            public Task Invoke(OutgoingTransportContext context, Func<Task> next)
            {
                var step = this.factory();

                return step.Invoke(context, next);
            }
Esempio n. 11
0
        private Task InvokeTransport(OutgoingTransportContext context)
        {
            if (this.executingTransportPipeline.Count == 0)
            {
                return Task.FromResult(0);
            }

            IOutgoingTransportStep step = this.executingTransportPipeline.Dequeue();

            return step.Invoke(context, () => this.InvokeTransport(context));
        }