Exemplo n.º 1
0
        protected override void OnEventApplied(UncommittedEvent appliedEvent)
        {
            base.OnEventApplied(appliedEvent);
            var callbacks = _eventAppliedCallbacks.Value;

            foreach(var callback in callbacks)
            {
                Log.DebugFormat("Calling event applied callback {0} for event {1} in aggregate root {2}", callback.GetHashCode(), appliedEvent, this);
                callback(this, appliedEvent);
            }
        }
Exemplo n.º 2
0
            public UncommittedEventStream ForSourceUncomitted(Guid id, Guid commitId, int sequenceOffset = 0)
            {                
                int initialVersion = sequenceOffset == 0 ? 1 : sequenceOffset;
                int sequence = initialVersion;

                var comittedEvents = new List<CommittedEvent>();
                var result = new UncommittedEventStream(commitId);
                foreach (var evnt in _events)
                {
                    var uncommittedEvent = new UncommittedEvent(Guid.NewGuid(), id, sequence, initialVersion, DateTime.UtcNow,
                                                            evnt, new Version(1, 0));
                    result.Append(uncommittedEvent);
                    sequence++;
                }
                return result;
            }
Exemplo n.º 3
0
 public IEnumerable<IProcessingElement> Fetch(string pipelineName, int maxCount)
 {
     lock (this)
     {
         int count = _random.Next(maxCount);
         int available = Count - _fetched;
         count = count > available ? available : count;
         for (int i = 0; i < count; i++)
         {
             _fetched++;
             var evnt = new UncommittedEvent(Guid.NewGuid(), Guid.NewGuid(), _fetched, _fetched, DateTime.Now, new object(),
                                             new Version(1, 0));
             yield return new SourcedEventProcessingElement(evnt);
         }
     }
 }
 public void SetUp()
 {
     _testEvent = new UncommittedEvent(Guid.NewGuid(), Guid.NewGuid(), 1, 1, DateTime.UtcNow, new FakeEvent(),
                                       new Version(1, 0));
     _handler1 = MockRepository.GenerateMock<IEventHandler<FakeEvent>>();
     _handler2 = MockRepository.GenerateMock<IEventHandler<FakeEventBase>>();
     _handler3 = MockRepository.GenerateMock<IEventHandler<IFakeEventInterface>>();
     _container = new WindsorContainer();
     _container.Register(
         Component.For<IWindsorContainer>().Instance(_container),
         Component.For<IEventHandler<FakeEvent>>().Instance(_handler1),
         Component.For<IEventHandler<FakeEventBase>>().Instance(_handler2),
         Component.For<IEventHandler<IFakeEventInterface>>().Instance(_handler3),
         Component.For<IEventBus>().ImplementedBy<WindsorInProcessEventBus>());
     var svc = _container.Resolve<IEventBus>();
     svc.Publish(_testEvent);
 }
 public void SetUp()
 {
     _testEvent = new UncommittedEvent(Guid.NewGuid(), Guid.NewGuid(), 1, 1, DateTime.UtcNow, new FakeEvent(),
                                       new Version(1, 0));
     _handler1 = new Mock<IEventHandler<FakeEvent>>(MockBehavior.Strict);
     _handler1.Setup(x => x.Handle(It.IsAny<IPublishedEvent<FakeEvent>>())).Verifiable();
     _handler2 = new Mock<IEventHandler<FakeEventBase>>(MockBehavior.Strict);
     _handler2.Setup(x => x.Handle(It.IsAny<IPublishedEvent<FakeEventBase>>())).Verifiable();
     _handler3 = new Mock<IEventHandler<IFakeEventInterface>>(MockBehavior.Strict);
     _handler3.Setup(x => x.Handle(It.IsAny<IPublishedEvent<IFakeEventInterface>>())).Verifiable();
     _container = new WindsorContainer();
     _container.Register(
         Component.For<IWindsorContainer>().Instance(_container),
         Component.For<IEventHandler<FakeEvent>>().Instance(_handler1.Object),
         Component.For<IEventHandler<FakeEvent>>().Instance(_handler2.Object),
         Component.For<IEventHandler<FakeEvent>>().Instance(_handler3.Object),
         Component.For<IEventBus>().ImplementedBy<WindsorInProcessEventBus>());
     var svc = _container.Resolve<IEventBus>();
     svc.Publish(_testEvent);
 }
Exemplo n.º 6
0
 protected override void AggregateRootEventAppliedHandler(AggregateRoot aggregateRoot, UncommittedEvent evnt)
 {
     RegisterDirtyInstance(aggregateRoot);            
     _eventStream.Append(evnt);
 }
Exemplo n.º 7
0
 protected override void OnEventApplied(UncommittedEvent appliedEvent);
Exemplo n.º 8
0
 private void AggregateRootEventAppliedHandler(AggregateRoot aggregateRoot, UncommittedEvent evnt)
 {
     _events.Add(evnt);
 }
 protected override void OnEventApplied(UncommittedEvent appliedEvent)
 {
     base.OnEventApplied(appliedEvent);
     _uncomittedEvents.Add(appliedEvent);
 }