Esempio n. 1
0
        protected override void DoSetUp()
        {
            _seqNos.Clear();

            var database = MongoHelper.InitializeTestDatabase();

            _source = new MongoDbEventStore(database, "EventSrc");
            _destination = new MongoDbEventStore(database, "EventDst");

            _replicator = new EventReplicator(_source, _destination);

            RegisterForDisposal(_replicator);

            _replicator.Start();
        }
Esempio n. 2
0
        public void TryReplicating()
        {
            var serializer = new JsonDomainEventSerializer();
            var source = new InMemoryEventStore();
            var destination = new InMemoryEventStore();
            var seqNo = 0;

            Func<string, EventData> getRecognizableEvent = text => serializer.Serialize(new RecognizableEvent(text)
            {
                Meta =
                {
                    {DomainEvent.MetadataKeys.AggregateRootId, "268DD0C0-529F-4242-9D53-601A88BB1813"},
                    {DomainEvent.MetadataKeys.SequenceNumber, (seqNo).ToString(Metadata.NumberCulture)},
                    {DomainEvent.MetadataKeys.GlobalSequenceNumber, (seqNo++).ToString(Metadata.NumberCulture)},
                }
            });

            // arrange
            using (var eventReplicator = new EventReplicator(source, destination))
            {
                eventReplicator.Start();
                Thread.Sleep(TimeSpan.FromSeconds(2));

                // act
                source.Save(Guid.NewGuid(), new[] { getRecognizableEvent("hello") });
                source.Save(Guid.NewGuid(), new[] { getRecognizableEvent("there") });
                source.Save(Guid.NewGuid(), new[] { getRecognizableEvent("my") });
                source.Save(Guid.NewGuid(), new[] { getRecognizableEvent("friend") });

                Thread.Sleep(TimeSpan.FromSeconds(1));
            }

            // assert
            var greeting = string.Join(" ", destination
                .Select(x => serializer.Deserialize(x))
                .OfType<RecognizableEvent>()
                .Select(e => e.Id));

            Assert.That(greeting, Is.EqualTo("hello there my friend"));
        }
Esempio n. 3
0
        protected override void DoSetUp()
        {
            _listLoggerFactory = new ListLoggerFactory();
            CirqusLoggerFactory.Current = _listLoggerFactory;

            _seqNos.Clear();

            var database = MongoHelper.InitializeTestDatabase();

            _source = new MongoDbEventStore(database, "EventSrc");
            _destination = new MongoDbEventStore(database, "EventDst");

            var source = new ThrowsAnErrorOnceInAWhile(_source, 0.5);
            var destination = new ThrowsAnErrorOnceInAWhile(_destination, 0.5);

            _replicator = new EventReplicator(source, destination)
            {
                TimeToPauseOnError = TimeSpan.Zero //< don't wait in this test
            };

            RegisterForDisposal(_replicator);

            _replicator.Start();
        }
 EventReplicator CreateAndStartReplication(IEventStore aalborgEventStore, IEventStore hongKongEventStore, TimeSpan replicationDelay)
 {
     var replicator = new EventReplicator(aalborgEventStore, new EventReplicatorDelayer(hongKongEventStore, replicationDelay));
     RegisterForDisposal(replicator);
     replicator.Start();
     return replicator;
 }