Exemplo n.º 1
0
        public Task Invoke(OutgoingLogicalContext context, Func <Task> next)
        {
            DeliveryOptions options = context.Options;

            var toSend = new TransportMessage {
                MessageIntent = MessageIntent.Publish
            };
            var sendOptions = options as SendOptions;

            if (sendOptions != null)
            {
                toSend.MessageIntent           = sendOptions is ReplyOptions ? MessageIntent.Reply : MessageIntent.Send;
                toSend.ReplyTo                 = sendOptions.ReplyToAddress;
                toSend.ScheduledEnqueueTimeUtc = sendOptions.ScheduledEnqueueTimeUtc;

                if (sendOptions.CorrelationId != null)
                {
                    toSend.CorrelationId = sendOptions.CorrelationId;
                }
            }

            foreach (var headerEntry in context.LogicalMessage.Headers)
            {
                toSend.Headers[headerEntry.Key] = headerEntry.Value;
            }

            context.Set(toSend);

            return(next());
        }
        public Task Invoke(OutgoingLogicalContext context, Func<Task> next)
        {
            DeliveryOptions options = context.Options;

            var toSend = new TransportMessage { MessageIntent = MessageIntent.Publish };
            var sendOptions = options as SendOptions;

            if (sendOptions != null)
            {
                toSend.MessageIntent = sendOptions is ReplyOptions ? MessageIntent.Reply : MessageIntent.Send;
                toSend.ReplyTo = sendOptions.ReplyToAddress;
                toSend.ScheduledEnqueueTimeUtc = sendOptions.ScheduledEnqueueTimeUtc;

                if (sendOptions.CorrelationId != null)
                {
                    toSend.CorrelationId = sendOptions.CorrelationId;
                }
            }

            foreach (var headerEntry in context.LogicalMessage.Headers)
            {
                toSend.Headers[headerEntry.Key] = headerEntry.Value;
            }

            context.Set(toSend);

            return next();
        }
Exemplo n.º 3
0
        private Task InvokeLogical(OutgoingLogicalContext context)
        {
            if (this.executingLogicalPipeline.Count == 0)
            {
                return(Task.FromResult(0));
            }

            IOutgoingLogicalStep step = this.executingLogicalPipeline.Dequeue();

            return(step.Invoke(context, () => this.InvokeLogical(context)));
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
0
            public Task Invoke(OutgoingLogicalContext context, Func <Task> next)
            {
                var step = this.factory();

                return(step.Invoke(context, next));
            }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
0
            public Task Invoke(OutgoingLogicalContext context, Func<Task> next)
            {
                var step = this.factory();

                return step.Invoke(context, next);
            }
Exemplo n.º 8
0
        private Task InvokeLogical(OutgoingLogicalContext context)
        {
            if (this.executingLogicalPipeline.Count == 0)
            {
                return Task.FromResult(0);
            }

            IOutgoingLogicalStep step = this.executingLogicalPipeline.Dequeue();

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