Ejemplo n.º 1
0
 public void BeforeEachTest()
 {
     sessionFactory = new DbContextSessionFactory();
     uow            = new DbUnitOfWork(sessionFactory);
     persister      = new DbSagaPersister(sessionFactory);
     saga           = GetTestSaga();
 }
 public void BeforeEachTest()
 {
     sessionFactory = new DbContextSessionFactory();
     uow = new DbUnitOfWork(sessionFactory);
     persister = new DbSagaPersister(sessionFactory);
     saga = GetTestSaga();
 }
Ejemplo n.º 3
0
        private static void Main(string[] args)
        {
            Database.SetInitializer(new SagaDatabaseInitializer());
            var sessionFactory = new DbContextSessionFactory();
            var persister = new DbSagaPersister(sessionFactory);
            var saga = new SimpleSagaData
                           {
                               Id = Guid.NewGuid(),
                               BusinessId = 1
                           };
            persister.Save(saga);

            var action = new Action(() =>
                                        {
                                            while (true)
                                            {
                                                try
                                                {
                                                    persister.Update(saga);
                                                }
                                                catch (DbUpdateConcurrencyException exc)
                                                {
                                                    Console.WriteLine("Optimistic concurrency check failed.");
                                                }
                                            }
                                        });

            var task1 = new Task(action);
            var task2 = new Task(action);
            task1.Start();
            task2.Start();

            Console.WriteLine("Processing...");
            Console.ReadLine();
        }
Ejemplo n.º 4
0
        private static void Main(string[] args)
        {
            Database.SetInitializer(new SagaDatabaseInitializer());
            var sessionFactory = new DbContextSessionFactory();
            var persister      = new DbSagaPersister(sessionFactory);
            var saga           = new SimpleSagaData
            {
                Id         = Guid.NewGuid(),
                BusinessId = 1
            };

            persister.Save(saga);

            var action = new Action(() =>
            {
                while (true)
                {
                    try
                    {
                        persister.Update(saga);
                    }
                    catch (DbUpdateConcurrencyException exc)
                    {
                        Console.WriteLine("Optimistic concurrency check failed.");
                    }
                }
            });

            var task1 = new Task(action);
            var task2 = new Task(action);

            task1.Start();
            task2.Start();

            Console.WriteLine("Processing...");
            Console.ReadLine();
        }