public CorrelatedSagaSubscriptionConnector(ISagaRepository <TSaga> sagaRepository, DataEvent <TSaga, TMessage> dataEvent,
                                                   IEnumerable <State> states,
                                                   ISagaPolicyFactory policyFactory,
                                                   Expression <Func <TSaga, bool> > removeExpression)
        {
            _sagaRepository = sagaRepository;
            _dataEvent      = dataEvent;

            _policy = policyFactory.GetPolicy <TSaga, TMessage>(states, x => x.CorrelationId, removeExpression);
        }
Пример #2
0
        public Saga(IWorkerSelectorFactory workerSelectorFactory,
                    ISagaRepository <TSaga> sagaRepository, DataEvent <TSaga, TMessage> dataEvent,
                    IEnumerable <State> states,
                    ISagaPolicyFactory policyFactory,
                    Expression <Func <TSaga, bool> > removeExpression)
        {
            _workerSelectorFactory = workerSelectorFactory;
            _sagaRepository        = sagaRepository;
            _dataEvent             = dataEvent;

            _policy = policyFactory.GetPolicy <TSaga, TMessage>(states, x => x.CorrelationId, removeExpression);
        }
        public PropertySagaSubscriptionConnector(ISagaRepository <TSaga> sagaRepository, DataEvent <TSaga, TMessage> dataEvent,
                                                 IEnumerable <State> states,
                                                 ISagaPolicyFactory policyFactory,
                                                 Expression <Func <TSaga, bool> > removeExpression,
                                                 Expression <Func <TSaga, TMessage, bool> > selector)
        {
            _sagaRepository = sagaRepository;
            _dataEvent      = dataEvent;
            _selector       = selector;

            Func <TMessage, Guid> getNewSagaId = GenerateGetSagaIdFunction(selector);

            _policy = policyFactory.GetPolicy(states, getNewSagaId, removeExpression);
        }
Пример #4
0
        public CorrelatedEventSagaDistributorConnector(IWorkerSelectorFactory workerSelectorFactory,
                                                       ISagaRepository <TSaga> sagaRepository,
                                                       DataEvent <TSaga, TMessage> dataEvent,
                                                       IEnumerable <State> states,
                                                       ISagaPolicyFactory policyFactory,
                                                       Expression <Func <TSaga, bool> > removeExpression)
        {
            _workerSelectorFactory = workerSelectorFactory;
            _sagaRepository        = sagaRepository;
            _dataEvent             = dataEvent;

            Func <TMessage, Guid> getNewSagaId = message => message.CorrelationId;

            _policy = policyFactory.GetPolicy(states, getNewSagaId, removeExpression);
        }
        public PropertySagaSubscriptionConnector(ISagaRepository <TSaga> sagaRepository,
                                                 DataEvent <TSaga, TMessage> dataEvent,
                                                 IEnumerable <State> states,
                                                 ISagaPolicyFactory policyFactory,
                                                 Expression <Func <TSaga, bool> > removeExpression,
                                                 IEventBinder <TSaga> eventBinder)
        {
            _sagaRepository = sagaRepository;
            _dataEvent      = dataEvent;

            _bindExpression = eventBinder.GetBindExpression <TMessage>();

            Func <TMessage, Guid> correlationIdSelector = GetCorrelationIdSelector(eventBinder);

            _policy = policyFactory.GetPolicy(states, correlationIdSelector, removeExpression);
        }
        public IPipelineSink <TMessage> Create(DataEvent <TSaga, TMessage> eevent, IEnumerable <State> states)
        {
            Type messageType = typeof(TMessage);

            Expression <Func <TSaga, bool> > removeExpression = SagaStateMachine <TSaga> .GetCompletedExpression();

            ISagaPolicy <TSaga, TMessage> policy = _policyFactory.GetPolicy <TSaga, TMessage>(states, removeExpression);

            Expression <Func <TSaga, TMessage, bool> > expression;

            if (SagaStateMachine <TSaga> .TryGetCorrelationExpressionForEvent(eevent, out expression))
            {
                return(this.FastInvoke <SagaStateMachineMessageSinkFactory <TSaga, TMessage>, IPipelineSink <TMessage> >("CreateSink", eevent, policy, expression));
            }

            // we check for a standard correlation interface second
            if (messageType.GetInterfaces().Where(x => x == typeof(CorrelatedBy <Guid>)).Count() > 0)
            {
                return(this.FastInvoke <SagaStateMachineMessageSinkFactory <TSaga, TMessage>, IPipelineSink <TMessage> >("CreateCorrelatedSink", eevent, policy));
            }

            throw new NotSupportedException("No method to connect to event was found for " + typeof(TMessage).FullName);
        }
Пример #7
0
 protected override ISagaPolicy <TSaga, TMessage> GetPolicy()
 {
     return(_policyFactory.GetPolicy <TSaga, TMessage>(_states, x => x.CorrelationId, _removeExpression));
 }