public TSaga Create(ConsumeContext <TMessage> context) { if (!context.CorrelationId.HasValue) { throw new SagaException("The correlationId was not present and the saga could not be created", typeof(TSaga), typeof(TMessage)); } return(SagaMetadataCache <TSaga> .FactoryMethod(context.CorrelationId.Value)); }
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); 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)); }