Example #1
0
        Task InvokeTransport(OutgoingTransportContext context)
        {
            if (executingTransportPipeline.Count == 0)
            {
                return(Task.FromResult(0));
            }

            IOutgoingTransportStep step = executingTransportPipeline.Dequeue();

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

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

            executingTransportPipeline = new Queue<IOutgoingTransportStep>(registeredTransportPipelineSteps);
            var transportContext = new OutgoingTransportContext(outgoingLogicalMessage, outgoingTransportMessage, options, configuration, incomingTransportMessage);
            await InvokeTransport(transportContext)
                .ConfigureAwait(false);
        }
        public async Task Invoke(OutgoingTransportContext context, Func<Task> next)
        {
            using (var ms = new MemoryStream())
            {
                serializer.Serialize(context.LogicalMessage.Instance, ms);

                context.OutgoingTransportMessage.ContentType = 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())
            {
                serializer.Serialize(context.LogicalMessage.Instance, ms);

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

                context.OutgoingTransportMessage.SetBody(ms);

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

            await InvokeLogical(logicalContext)
            .ConfigureAwait(false);

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

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

            await InvokeTransport(transportContext)
            .ConfigureAwait(false);
        }
        public async Task Invoke(OutgoingTransportContext context, Func<Task> next)
        {
            var sendOptions = context.Options as SendOptions;
            if (sendOptions != null)
            {
                await sender.SendAsync(context.OutgoingTransportMessage, sendOptions)
                    .ConfigureAwait(false);
            }

            var publishOptions = context.Options as PublishOptions;
            if (publishOptions != null)
            {
                await 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 = GetDestinationForSend(context.LogicalMessage.Instance);
// ReSharper restore PossibleNullReferenceException
            }

            var publishOptions = context.Options as PublishOptions;
            if (ShouldDeterminePublishDestination(publishOptions))
            {
// ReSharper disable PossibleNullReferenceException
                publishOptions.Topic = 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 sender.SendAsync(context.OutgoingTransportMessage, sendOptions)
                .ConfigureAwait(false);
            }

            var publishOptions = context.Options as PublishOptions;

            if (publishOptions != null)
            {
                await 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 = GetDestinationForSend(context.LogicalMessage.Instance);
// ReSharper restore PossibleNullReferenceException
            }

            var publishOptions = context.Options as PublishOptions;

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

            return(next());
        }
Example #10
0
            public Task Invoke(OutgoingTransportContext context, Func<Task> next)
            {
                var step = factory();

                return step.Invoke(context, next);
            }
Example #11
0
        Task InvokeTransport(OutgoingTransportContext context)
        {
            if (executingTransportPipeline.Count == 0)
            {
                return Task.FromResult(0);
            }

            IOutgoingTransportStep step = executingTransportPipeline.Dequeue();

            return step.Invoke(context, () => InvokeTransport(context));
        }
Example #12
0
            public Task Invoke(OutgoingTransportContext context, Func <Task> next)
            {
                var step = factory();

                return(step.Invoke(context, next));
            }