Example #1
0
        public Task Send(ConsumeContext <TMessage> context, IPipe <SagaConsumeContext <TSaga, TMessage> > next)
        {
            if (!context.CorrelationId.HasValue)
            {
                throw new SagaException("The correlationId was not present and the saga could not be created", typeof(TSaga), typeof(TMessage));
            }

            TSaga instance = SagaMetadataCache <TSaga> .FactoryMethod(context.CorrelationId.Value);

            var proxy = new NewSagaConsumeContext <TSaga, TMessage>(context, instance);

            proxy.LogCreated();

            return(next.Send(proxy));
        }
Example #2
0
        public Task Send(ConsumeContext <TMessage> context, IPipe <SagaConsumeContext <TSaga, TMessage> > next)
        {
            if (!context.CorrelationId.HasValue)
            {
                throw new SagaException("The correlationId was not present and the saga could not be created", typeof(TSaga), typeof(TMessage));
            }

            TSaga instance = _factoryMethod(context);

            if (_log.IsDebugEnabled)
            {
                _log.DebugFormat("SAGA:{0}:{1} Created {2}", TypeMetadataCache <TSaga> .ShortName, instance.CorrelationId, TypeMetadataCache <TMessage> .ShortName);
            }

            var proxy = new NewSagaConsumeContext <TSaga, TMessage>(context, instance);

            return(next.Send(proxy));
        }