Пример #1
0
        // virtual for testing as usual
        public virtual async Task<IContinuation> FindContinuation(Envelope envelope, IEnvelopeContext context)
        {
            foreach (var handler in _handlers)
            {
                var continuation = await handler.Handle(envelope).ConfigureAwait(false);
                if (continuation != null)
                {
                    context.DebugMessage(() => new EnvelopeContinuationChosen
                    {   
                        ContinuationType = continuation.GetType(),
                        HandlerType = handler.GetType(),
                        Envelope = envelope.ToToken()
                    });

                    return continuation;
                }
            }

            // TODO - add rules for what to do when we have no handler
            context.DebugMessage(() => new EnvelopeContinuationChosen
            {
                ContinuationType = typeof(MoveToErrorQueue),
                HandlerType = typeof(HandlerPipeline),
                Envelope = envelope.ToToken()
            });

            return new MoveToErrorQueue(new NoHandlerException(envelope.Message.GetType()));
        }
Пример #2
0
        // virtual for testing as usual
        public virtual async Task <IContinuation> FindContinuation(Envelope envelope, IEnvelopeContext context)
        {
            foreach (var handler in _handlers)
            {
                var continuation = await handler.Handle(envelope).ConfigureAwait(false);

                if (continuation != null)
                {
                    context.DebugMessage(() => new EnvelopeContinuationChosen
                    {
                        ContinuationType = continuation.GetType(),
                        HandlerType      = handler.GetType(),
                        Envelope         = envelope.ToToken()
                    });

                    return(continuation);
                }
            }

            // TODO - add rules for what to do when we have no handler
            context.DebugMessage(() => new EnvelopeContinuationChosen
            {
                ContinuationType = typeof(MoveToErrorQueue),
                HandlerType      = typeof(HandlerPipeline),
                Envelope         = envelope.ToToken()
            });

            return(new MoveToErrorQueue(new NoHandlerException(envelope.Message.GetType())));
        }