Beispiel #1
0
        /// <summary>
        /// Subscribe a state machine saga to the endpoint
        /// </summary>
        /// <typeparam name="TInstance">The state machine instance type</typeparam>
        /// <param name="configurator"></param>
        /// <param name="scope">The Autofac Lifetime Container to resolve the repository</param>
        /// <param name="configure">Optionally configure the saga</param>
        /// <param name="name">The name to use for the scope created for each message</param>
        /// <param name="configureScope">Configuration for scope container</param>
        /// <returns></returns>
        public static void StateMachineSaga <TInstance>(this IReceiveEndpointConfigurator configurator, ILifetimeScope scope,
                                                        Action <ISagaConfigurator <TInstance> > configure = null, string name = "message", Action <ContainerBuilder, ConsumeContext> configureScope = null)
            where TInstance : class, SagaStateMachineInstance
        {
            ISagaStateMachineFactory stateMachineFactory = new AutofacSagaStateMachineFactory(scope);

            SagaStateMachine <TInstance> stateMachine = stateMachineFactory.CreateStateMachine <TInstance>();

            StateMachineSaga(configurator, stateMachine, scope, configure, name, configureScope);
        }
Beispiel #2
0
        public static ConnectHandle ConnectStateMachineSaga <TInstance>(this IConsumePipeConnector pipe, ILifetimeScope scope, string name = "message",
                                                                        Action <ContainerBuilder, ConsumeContext> configureScope           = null)
            where TInstance : class, SagaStateMachineInstance
        {
            ISagaStateMachineFactory stateMachineFactory = new AutofacSagaStateMachineFactory(scope);

            SagaStateMachine <TInstance> stateMachine = stateMachineFactory.CreateStateMachine <TInstance>();

            return(pipe.ConnectStateMachineSaga(stateMachine, scope, name, configureScope));
        }
        /// <summary>
        /// Subscribe a state machine saga to the endpoint
        /// </summary>
        /// <typeparam name="TInstance">The state machine instance type</typeparam>
        /// <param name="configurator"></param>
        /// <param name="scope">The StructureMap Container to resolve the repository</param>
        /// <param name="configure">Optionally configure the saga</param>
        /// <returns></returns>
        public static void StateMachineSaga <TInstance>(this IReceiveEndpointConfigurator configurator, ILifetimeScope scope, Action <ISagaConfigurator <TInstance> > configure = null)
            where TInstance : class, SagaStateMachineInstance
        {
            ISagaStateMachineFactory stateMachineFactory = new AutofacSagaStateMachineFactory(scope);

            var stateMachine = stateMachineFactory.CreateStateMachine <TInstance>();

            ISagaRepositoryFactory repositoryFactory = new AutofacStateMachineSagaRepositoryFactory(new SingleLifetimeScopeProvider(scope), "message");

            var sagaRepository = repositoryFactory.CreateSagaRepository <TInstance>();

            var stateMachineConfigurator = new StateMachineSagaConfigurator <TInstance>(stateMachine, sagaRepository, configurator);

            configure?.Invoke(stateMachineConfigurator);

            configurator.AddEndpointSpecification(stateMachineConfigurator);
        }
Beispiel #4
0
        /// <summary>
        /// Subscribe a state machine saga to the endpoint
        /// </summary>
        /// <typeparam name="TInstance">The state machine instance type</typeparam>
        /// <param name="configurator"></param>
        /// <param name="context">The Autofac root container to resolve the repository</param>
        /// <param name="configure">Optionally configure the saga</param>
        /// <param name="name">The name to use for the scope created for each message</param>
        /// <param name="configureScope">Configuration for scope container</param>
        /// <returns></returns>
        public static void StateMachineSaga <TInstance>(this IReceiveEndpointConfigurator configurator, IComponentContext context, Action <ISagaConfigurator <TInstance> > configure = null,
                                                        string name = "message",
                                                        Action <ContainerBuilder, ConsumeContext> configureScope = null)
            where TInstance : class, SagaStateMachineInstance
        {
            var scope = context.Resolve <ILifetimeScope>();

            ISagaStateMachineFactory stateMachineFactory = new AutofacSagaStateMachineFactory(scope);

            SagaStateMachine <TInstance> stateMachine = stateMachineFactory.CreateStateMachine <TInstance>();

            ISagaRepositoryFactory repositoryFactory = new AutofacStateMachineSagaRepositoryFactory(new SingleLifetimeScopeProvider(scope), name, configureScope);

            ISagaRepository <TInstance> sagaRepository = repositoryFactory.CreateSagaRepository <TInstance>();

            var stateMachineConfigurator = new StateMachineSagaConfigurator <TInstance>(stateMachine, sagaRepository, configurator);

            configure?.Invoke(stateMachineConfigurator);

            configurator.AddEndpointSpecification(stateMachineConfigurator);
        }