示例#1
0
        Task InvokeTransport(IncomingTransportContext context, IBusForHandler bus)
        {
            if (executingTransportPipeline.Count == 0)
            {
                return(Task.FromResult(0));
            }

            IIncomingTransportStep step = executingTransportPipeline.Dequeue();

            return(step.Invoke(context, bus, () => InvokeTransport(context, bus)));
        }
示例#2
0
        Task InvokeTransport(IncomingTransportContext context, IBusForHandler bus, int currentIndex = 0)
        {
            if (currentIndex == registeredTransportPipeline.Count)
            {
                return(Task.CompletedTask);
            }

            IIncomingTransportStep step = registeredTransportPipeline[currentIndex];

            return(step.Invoke(context, bus, () => InvokeTransport(context, bus, currentIndex + 1)));
        }
        public async Task Invoke(IBusForHandler bus, TransportMessage message, EndpointConfiguration.ReadOnly configuration)
        {
            var transportContext = new IncomingTransportContext(message, configuration);
            await InvokeTransport(transportContext, bus)
                .ConfigureAwait(false);

            // We assume that someone in the pipeline made logical message
            var logicalMessage = transportContext.Get<LogicalMessage>();

            var logicalContext = new IncomingLogicalContext(logicalMessage, message, configuration);
            currentContext = logicalContext;
            await InvokeLogical(logicalContext, bus)
                .ConfigureAwait(false);
        }
示例#4
0
        public Task Invoke(IncomingTransportContext context, IBusForHandler bus, Func <Task> next)
        {
            var transportMessage = context.TransportMessage;

            try
            {
                context.Set(Extract(transportMessage));
            }
            catch (Exception exception)
            {
                throw new SerializationException(string.Format("An error occurred while attempting to extract logical messages from transport message {0}", transportMessage), exception);
            }

            return(next());
        }
        public Task Invoke(IncomingTransportContext context, IBusForHandler bus, Func<Task> next)
        {
            var transportMessage = context.TransportMessage;

            try
            {
                context.Set(Extract(transportMessage));
            }
            catch (Exception exception)
            {
                throw new SerializationException(string.Format("An error occurred while attempting to extract logical messages from transport message {0}", transportMessage), exception);
            }

            return next();
        }
示例#6
0
        public async Task Invoke(IBusForHandler bus, TransportMessage message, EndpointConfiguration.ReadOnly configuration)
        {
            var transportContext = new IncomingTransportContext(message, configuration);

            await InvokeTransport(transportContext, bus)
            .ConfigureAwait(false);

            // We assume that someone in the pipeline made logical message
            var logicalMessage = transportContext.Get <LogicalMessage>();

            var logicalContext = new IncomingLogicalContext(logicalMessage, message, configuration);

            currentContext = logicalContext;
            await InvokeLogical(logicalContext, bus)
            .ConfigureAwait(false);
        }
示例#7
0
        public async Task Invoke(IBusForHandler bus, TransportMessage message, EndpointConfiguration.ReadOnly configuration)
        {
            executingTransportPipeline = new Queue<IIncomingTransportStep>(registeredTransportPipeline);
            var transportContext = new IncomingTransportContext(message, configuration);
            transportContext.SetChain(this);
            await InvokeTransport(transportContext, bus)
                .ConfigureAwait(false);

            // We assume that someone in the pipeline made logical message
            var logicalMessage = transportContext.Get<LogicalMessage>();

            executingLogicalPipeline = new Queue<IIncomingLogicalStep>(registeredLogicalPipeline);
            var logicalContext = new IncomingLogicalContext(logicalMessage, message, configuration);
            logicalContext.SetChain(this);
            currentContext = logicalContext;
            await InvokeLogical(logicalContext, bus)
                .ConfigureAwait(false);
        }
        public async Task Invoke(IncomingTransportContext context, IBusForHandler bus, Func<Task> next)
        {
            try
            {
                await next()
                    .ConfigureAwait(false);
            }
            catch (SerializationException exception)
            {
                var message = context.TransportMessage;

                message.SetFailureHeaders(exception, "Messages which can't be deserialized are deadlettered immediately");
                await deadLetter.DeadLetterAsync(message)
                    .ConfigureAwait(false);

                // Because we instructed the message to deadletter it is safe to rethrow. The broker will not redeliver.
                throw;
            }
        }
示例#9
0
        public async Task Invoke(IncomingTransportContext context, IBusForHandler bus, Func <Task> next)
        {
            try
            {
                await next()
                .ConfigureAwait(false);
            }
            catch (SerializationException exception)
            {
                var message = context.TransportMessage;

                message.SetFailureHeaders(exception, "Messages which can't be deserialized are deadlettered immediately");
                await deadLetter.DeadLetterAsync(message)
                .ConfigureAwait(false);

                // Because we instructed the message to deadletter it is safe to rethrow. The broker will not redeliver.
                throw;
            }
        }
示例#10
0
        public async Task Invoke(IBusForHandler bus, TransportMessage message, EndpointConfiguration.ReadOnly configuration)
        {
            executingTransportPipeline = new Queue <IIncomingTransportStep>(registeredTransportPipeline);
            var transportContext = new IncomingTransportContext(message, configuration);

            transportContext.SetChain(this);
            await InvokeTransport(transportContext, bus)
            .ConfigureAwait(false);

            // We assume that someone in the pipeline made logical message
            var logicalMessage = transportContext.Get <LogicalMessage>();

            executingLogicalPipeline = new Queue <IIncomingLogicalStep>(registeredLogicalPipeline);
            var logicalContext = new IncomingLogicalContext(logicalMessage, message, configuration);

            logicalContext.SetChain(this);
            currentContext = logicalContext;
            await InvokeLogical(logicalContext, bus)
            .ConfigureAwait(false);
        }
示例#11
0
            public Task Invoke(IncomingTransportContext context, IBusForHandler bus, Func<Task> next)
            {
                var step = factory();

                return step.Invoke(context, bus, next);
            }
示例#12
0
        Task InvokeTransport(IncomingTransportContext context, IBusForHandler bus)
        {
            if (executingTransportPipeline.Count == 0)
            {
                return Task.FromResult(0);
            }

            IIncomingTransportStep step = executingTransportPipeline.Dequeue();

            return step.Invoke(context, bus, () => InvokeTransport(context, bus));
        }
示例#13
0
            public Task Invoke(IncomingTransportContext context, IBusForHandler bus, Func <Task> next)
            {
                var step = factory();

                return(step.Invoke(context, bus, next));
            }
        Task InvokeTransport(IncomingTransportContext context, IBusForHandler bus, int currentIndex = 0)
        {
            if (currentIndex == registeredTransportPipeline.Count)
            {
                return Task.CompletedTask;
            }

            IIncomingTransportStep step = registeredTransportPipeline[currentIndex];

            return step.Invoke(context, bus, () => InvokeTransport(context, bus, currentIndex + 1));
        }