コード例 #1
0
        void ISagaRegistration.Configure(IReceiveEndpointConfigurator configurator, IConfigurationServiceProvider configurationServiceProvider)
        {
            var repository = configurationServiceProvider.GetRequiredService <ISagaRepository <TSaga> >();

            var decoratorRegistration = configurationServiceProvider.GetService <ISagaRepositoryDecoratorRegistration <TSaga> >();

            if (decoratorRegistration != null)
            {
                repository = decoratorRegistration.DecorateSagaRepository(repository);
            }

            var sagaConfigurator = new SagaConfigurator <TSaga>(repository, configurator);

            GetSagaDefinition(configurationServiceProvider)
            .Configure(configurator, sagaConfigurator);

            foreach (Action <ISagaConfigurator <TSaga> > action in _configureActions)
            {
                action(sagaConfigurator);
            }

            LogContext.Info?.Log("Configured endpoint {Endpoint}, Saga: {SagaType}", configurator.InputAddress.GetLastPart(),
                                 TypeMetadataCache <TSaga> .ShortName);

            configurator.AddEndpointSpecification(sagaConfigurator);
        }
コード例 #2
0
        /// <summary>
        /// Configure a saga subscription
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="configurator"></param>
        /// <param name="sagaRepository"></param>
        /// <param name="configure"></param>
        /// <returns></returns>
        public static void Saga <T>(this IReceiveEndpointConfigurator configurator, ISagaRepository <T> sagaRepository,
                                    Action <ISagaConfigurator <T> > configure = null)
            where T : class, ISaga
        {
            if (_log.IsDebugEnabled)
            {
                _log.DebugFormat("Subscribing Saga: {0}", TypeMetadataCache <T> .ShortName);
            }

            var sagaConfigurator = new SagaConfigurator <T>(sagaRepository);

            configure?.Invoke(sagaConfigurator);

            configurator.AddEndpointSpecification(sagaConfigurator);
        }
コード例 #3
0
        void ISagaRegistration.Configure(IReceiveEndpointConfigurator configurator, IConfigurationServiceProvider configurationServiceProvider)
        {
            var repositoryFactory = configurationServiceProvider.GetRequiredService <ISagaRepositoryFactory>();
            ISagaRepository <TSaga> sagaRepository = repositoryFactory.CreateSagaRepository <TSaga>();
            var sagaConfigurator = new SagaConfigurator <TSaga>(sagaRepository, configurator);

            GetSagaDefinition(configurationServiceProvider)
            .Configure(configurator, sagaConfigurator);

            foreach (Action <ISagaConfigurator <TSaga> > action in _configureActions)
            {
                action(sagaConfigurator);
            }

            configurator.AddEndpointSpecification(sagaConfigurator);
        }
コード例 #4
0
        void ISagaRegistration.Configure(IReceiveEndpointConfigurator configurator, IConfigurationServiceProvider configurationServiceProvider)
        {
            var repositoryFactory = configurationServiceProvider.GetRequiredService <ISagaRepositoryFactory>();
            ISagaRepository <TSaga> sagaRepository = repositoryFactory.CreateSagaRepository <TSaga>();
            var sagaConfigurator = new SagaConfigurator <TSaga>(sagaRepository, configurator);

            LogContext.Debug?.Log("Configuring endpoint {Endpoint}, Saga: {SagaType}", configurator.InputAddress.GetLastPart(), TypeMetadataCache <TSaga> .ShortName);

            GetSagaDefinition(configurationServiceProvider)
            .Configure(configurator, sagaConfigurator);

            foreach (Action <ISagaConfigurator <TSaga> > action in _configureActions)
            {
                action(sagaConfigurator);
            }

            configurator.AddEndpointSpecification(sagaConfigurator);
        }
コード例 #5
0
        /// <summary>
        /// Configure a saga subscription
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="configurator"></param>
        /// <param name="sagaRepository"></param>
        /// <param name="configure"></param>
        /// <returns></returns>
        public static void Saga <T>(this IReceiveEndpointConfigurator configurator, ISagaRepository <T> sagaRepository,
                                    Action <ISagaConfigurator <T> > configure = null)
            where T : class, ISaga
        {
            if (configurator == null)
            {
                throw new ArgumentNullException(nameof(configurator));
            }
            if (sagaRepository == null)
            {
                throw new ArgumentNullException(nameof(sagaRepository));
            }

            LogContext.Debug?.Log("Subscribing Saga: {SagaType}", TypeMetadataCache <T> .ShortName);

            var sagaConfigurator = new SagaConfigurator <T>(sagaRepository, configurator);

            configure?.Invoke(sagaConfigurator);

            configurator.AddEndpointSpecification(sagaConfigurator);
        }