示例#1
0
            public When_pre_inserting_in_an_invalid_state_with_ef()
            {
                ISagaDbContextFactory <Instance> sagaDbContextFactory = new DelegateSagaDbContextFactory <Instance>(
                    () => new SagaDbContext <Instance, EntityFrameworkInstanceMap>(SagaDbContextFactoryProvider.GetLocalDbConnectionString()));

                _repository = new EntityFrameworkSagaRepository <Instance>(sagaDbContextFactory);
            }
示例#2
0
            public When_pre_inserting_the_state_machine_instance_using_ef()
            {
                ISagaDbContextFactory <Instance> sagaDbContextFactory = new DelegateSagaDbContextFactory <Instance>(
                    () => new InstanceSagaDbContext(LocalDbConnectionStringProvider.GetLocalDbConnectionString()));

                _repository = EntityFrameworkSagaRepository <Instance> .CreatePessimistic(sagaDbContextFactory);
            }
示例#3
0
        public bool Start(HostControl theHostControl)
        {
            rabbitMQHostUrl      = ConfigurationManager.AppSettings["RabbitMQHost"];
            rabbitMQUsername     = ConfigurationManager.AppSettings["RabbitMQUsername"];
            rabbitMQPassword     = ConfigurationManager.AppSettings["RabbitMQPassword"];
            changeStateQueueName = ConfigurationManager.AppSettings["changestatequeuename"];


            theLogWriter.Info($"Creating Service {nameof(StateMachineService)}...");

            DelegateSagaDbContextFactory <StateInstance> delegateSagaDbContextFactory =
                new DelegateSagaDbContextFactory <StateInstance>(() => new MachineSagaDBContext("defaultDatabase"));

            theStateInstance = new EntityFrameworkSagaRepository <StateInstance>(delegateSagaDbContextFactory, System.Data.IsolationLevel.ReadCommitted);

            theBusControl = Bus.Factory.CreateUsingRabbitMq(cfg =>
            {
                IRabbitMqHost theRabbitHost = cfg.Host(new Uri(rabbitMQHostUrl), host =>
                {
                    host.Username(rabbitMQUsername);
                    host.Username(rabbitMQPassword);
                });

                //EndpointConvention.Map<AssignCarrierToOrder>(new Uri(string.Concat(rabbitMQHostUrl, "Here is the queue")));

                cfg.ReceiveEndpoint(changeStateQueueName, e =>
                {
                    e.PrefetchCount = 16;
                    e.UseInMemoryOutbox();

                    var machine = new StateMachine.StateMachine();
                    e.StateMachineSaga(machine, theStateInstance);
                });
            });

            theLogWriter.Info($"Service {nameof(StateMachineService)} created and ready to flight :D");
            theBusControl.Start();
            return(true);
        }