Beispiel #1
0
        private static void RetryWhileConcurrent(eRepositoryType repoType, Guid aggyId, int value)
        {
            while (true)
            {
                try
                {
                    Stopwatch sw = new Stopwatch();
                    sw.Start();

                    _log.Trace("Getting Aggregate [{0}]", aggyId);
                    var repo = new TestRepository(repoType);
                    var aggy = repo.GetSimpleAggregateById(aggyId, 0);
                    aggy.ChangeFoo(value);

                    _log.Trace("Saving Aggregate [{0}]", aggyId);
                    repo.Save(aggy, Guid.NewGuid(), null);

                    _log.Trace("Saved Aggregate [{0}]", aggyId);
                    break;
                }
                catch (ConcurrencyException)
                {
                    _log.Trace("Concurrency Detected, will retry shortly");
                    var rand = new Random();
                    Thread.Sleep(rand.Next(0, 200));                            // this is to increase race condition likelyhood
                }
                catch (Exception ex)
                {
                    _log.Trace("BAD!!!!!! Generic Exception, [{0}], we will let the aggregate retry though", ex.Message);
                    var rand = new Random();
                    Thread.Sleep(rand.Next(0, 200));                            // this is to increase race condition likelyhood
                }
            }
        }
Beispiel #2
0
        private static void SnapshotAggregate(eRepositoryType repoType, Guid aggyId)
        {
            var sw   = Stopwatch.StartNew();
            var repo = new TestRepository(repoType);
            var aggy = repo.GetSimpleAggregateById(aggyId, Int32.MaxValue);

            repo.Snapshot(aggy);
            _log.Info("Snapshot took [{0}] ms", sw.ElapsedMilliseconds);
        }
Beispiel #3
0
 public TestRepository(eRepositoryType repositoryType)
     : base(repositoryType)
 {
 }
Beispiel #4
0
 /// <summary>
 /// Create new NEventStoreRepositoryBase
 /// </summary>
 /// <param name="repositoryType"></param>
 public NEventStoreRepositoryBase(eRepositoryType repositoryType)
 {
     _repositoryType = repositoryType;
 }