public ISagaInstance <SoftwareProgrammingSaga, SoftwareProgrammingSagaData> Create(SleptWellEvent message)
        {
            var data = new SagaDataAggregate <SoftwareProgrammingSagaData>(message.SagaId,
                                                                           new SoftwareProgrammingSagaData(
                                                                               nameof(SoftwareProgrammingSaga.Coding)));

            return(Create(data));
        }
        public ISagaInstance <CustomRoutesSoftwareProgrammingSaga, SoftwareProgrammingSagaData> Create(SleptWellEvent message)
        {
            var saga = new CustomRoutesSoftwareProgrammingSaga();
            var data = new SagaDataAggregate <SoftwareProgrammingSagaData>(message.SofaId,
                                                                           new SoftwareProgrammingSagaData(saga.Sleeping.Name));

            return(SagaInstance.New(saga, data));
        }
        public ISagaInstance <CustomRoutesSoftwareProgrammingSaga, SoftwareProgrammingSagaData> Create(GotTiredEvent message)
        {
            var saga = new CustomRoutesSoftwareProgrammingSaga();
            var data = new SagaDataAggregate <SoftwareProgrammingSagaData>(message.PersonId,
                                                                           new SoftwareProgrammingSagaData(saga.Coding.Name));

            return(SagaInstance.New(saga, data));
        }
        public Given_AutomatonymousSaga(Func <SoftwareProgrammingSaga, State> initialState)
        {
            var sagaData = new SoftwareProgrammingSagaData(initialState(SagaMachine).Name);

            SagaDataAggregate = new SagaDataAggregate <SoftwareProgrammingSagaData>(Guid.NewGuid(),
                                                                                    sagaData);
            SagaInstance = new SagaInstance <SoftwareProgrammingSaga, SoftwareProgrammingSagaData>(SagaMachine, SagaDataAggregate);
        }
        public void When_publishing_start_message()
        {
            GridNode.NewDebugWaiter()
            .Expect <SagaCreatedEvent <SoftwareProgrammingSagaData> >()
            .Create()
            .Publish(StartMessage)
            .Wait();

            _sagaData = LoadAggregate <SagaDataAggregate <SoftwareProgrammingSagaData> >(StartMessage.SagaId);
        }
        public void When_publishing_start_message()
        {
            GridNode.NewDebugWaiter(Timeout)
            .Expect <SagaCreatedEvent <SoftwareProgrammingSagaData> >()
            .Create()
            .Publish(new SleptWellEvent(Guid.NewGuid(), Guid.NewGuid(), SagaId))
            .Wait();

            _sagaData = LoadAggregate <SagaDataAggregate <SoftwareProgrammingSagaData> >(SagaId);
        }
示例#7
0
        public void Saga_data_should_not_be_changed()
        {
            _coffeMadeEvent = (CoffeMadeEvent)
                              new CoffeMadeEvent(Guid.NewGuid(), Guid.NewGuid()).CloneWithSaga(Guid.NewGuid());

            GridNode.Transport.Publish(_coffeMadeEvent);
            Thread.Sleep(200);
            _sagaDataAggregate = LoadAggregate <SagaDataAggregate <SoftwareProgrammingSagaData> >(_coffeMadeEvent.SagaId);
            Assert.Null(_sagaDataAggregate.Data);
        }
示例#8
0
        public void When_publishing_start_message()
        {
            var waiter = GridNode.NewDebugWaiter(Timeout);

            ConfigureWait(waiter)
            .Create()
            .Publish(_sagaMessages)
            .Wait();

            SagaData = LoadAggregate <SagaDataAggregate <SoftwareProgrammingSagaData> >(_sagaId);
        }
        public void Test()
        {
            var saga  = new SoftwareProgrammingSaga();
            var state = new SoftwareProgrammingSagaData("123", Guid.NewGuid(), Guid.NewGuid());

            _sagaState = new SagaDataAggregate <SoftwareProgrammingSagaData>(Guid.NewGuid(), state);
            _sagaState.RememberEvent(saga.CoffeReady, state, new object());
            _sagaState.ClearEvents();

            var json = JsonConvert.SerializeObject(_sagaState);

            _restoredState = JsonConvert.DeserializeObject <SagaDataAggregate <SoftwareProgrammingSagaData> >(json);
        }
示例#10
0
        public void Test()
        {
            var saga  = new SoftwareProgrammingSaga();
            var state = new SoftwareProgrammingSagaData(saga.Coding.Name, Guid.NewGuid(), Guid.NewGuid());

            _sagaState = new SagaDataAggregate <SoftwareProgrammingSagaData>(Guid.NewGuid(), state);
            _sagaState.RememberEvent(saga.CoffeReady, state, new object());
            _sagaState.ClearEvents();

            var repo = new AggregateSnapshotRepository(AkkaConf.Persistence.JournalConnectionString, GridNode.AggregateFromSnapshotsFactory);

            repo.Add(_sagaState);

            _restoredState = LoadInstanceSagaState <SoftwareProgrammingSaga, SoftwareProgrammingSagaData>(_sagaState.Id);
        }
示例#11
0
        public void When_publishing_start_message()
        {
            var waiter = GridNode.NewDebugWaiter(Timeout);

            secondStartMessage = new SleptWellEvent(Guid.NewGuid(), Guid.NewGuid(), SagaId);


            waiter.Expect <SagaCreatedEvent <SoftwareProgrammingSagaData> >()
            .Create()
            .Publish(new GotTiredEvent(Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), SagaId))
            .Wait();

            LookupInstanceSagaActor <SoftwareProgrammingSaga, SoftwareProgrammingSagaData>(SagaId)
            .Tell(NotifyOnPersistenceEvents.Instance);

            Publisher.Publish(secondStartMessage);
            FishForMessage <Persisted>(m => true);

            SagaData = LoadAggregate <SagaDataAggregate <SoftwareProgrammingSagaData> >(SagaId);
        }
示例#12
0
        public void Test()
        {
            var saga  = new SoftwareProgrammingSaga();
            var state = new SoftwareProgrammingSagaData("123", Guid.NewGuid(), Guid.NewGuid());

            _sagaState = new SagaDataAggregate <SoftwareProgrammingSagaData>(Guid.NewGuid(), state);
            _sagaState.RememberEvent(saga.CoffeReady, state, new object());
            _sagaState.ClearEvents();

            var fixture  = new Fixture();
            var gotTired = fixture.Create <GotTiredEvent>();

            var factory  = new SoftwareProgrammingSagaFactory();
            var instance = factory.Create(gotTired);


            var json = JsonConvert.SerializeObject(_sagaState);

            _restoredState = JsonConvert.DeserializeObject <SagaDataAggregate <SoftwareProgrammingSagaData> >(json);
        }
        public void When_publishing_start_message()
        {
            _startMessage = (GotTiredEvent)
                            new GotTiredEvent(Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid())
                            .CloneWithSaga(Guid.NewGuid());

            _coffeMadeEvent = (CoffeMadeEvent)
                              new CoffeMadeEvent(_startMessage.FavoriteCoffeMachineId, _startMessage.PersonId)
                              .CloneWithSaga(_startMessage.SagaId);

            _reStartEvent = (GotTiredEvent)
                            new GotTiredEvent(Guid.NewGuid(), _startMessage.LovelySofaId, Guid.NewGuid())
                            .CloneWithSaga(_startMessage.SagaId);

            GridNode.Transport.Publish(_startMessage);
            GridNode.Transport.Publish(_coffeMadeEvent);
            GridNode.Transport.Publish(_reStartEvent);

            Thread.Sleep(3000);

            _sagaDataAggregate = LoadAggregate <SagaDataAggregate <SoftwareProgrammingSagaData> >(_startMessage.SagaId);
        }
        public void Given_instance_saga_When_recovering_from_creation()
        {
            var aggregateFactory = new AggregateFactory();
            var sagaId           = Guid.NewGuid();

            _data = aggregateFactory.Build <SagaDataAggregate <SoftwareProgrammingSagaData> >(sagaId);
            var saga         = new SoftwareProgrammingSaga();
            var initialState = new SoftwareProgrammingSagaData(saga.MakingCoffee.Name);

            var eventsToReplay = new DomainEvent[]
            {
                new SagaCreatedEvent <SoftwareProgrammingSagaData>(initialState, sagaId)
            };

            _data.ApplyEvents(eventsToReplay);

            _sagaInstance = SagaInstance.New(saga, _data);

            //Try to transit saga by message, available only in desired state
            _coffeMakeFailedEvent = new CoffeMakeFailedEvent(Guid.NewGuid(), Guid.NewGuid());
            _sagaInstance.Transit(_coffeMakeFailedEvent);
            _dispatchedCommands = _sagaInstance.CommandsToDispatch;
        }
        public void When_publishing_start_message()
        {
            var sagaId = Guid.NewGuid();

            _sagaData = new SoftwareProgrammingSagaData(nameof(SoftwareProgrammingSaga.MakingCoffee))
            {
                PersonId = Guid.NewGuid()
            };

            var sagaDataEvent = new SagaCreatedEvent <SoftwareProgrammingSagaData>(_sagaData, sagaId);

            SaveInJournal <SagaDataAggregate <SoftwareProgrammingSagaData> >(sagaId, sagaDataEvent);

            Thread.Sleep(100);
            _coffeMakeFailedEvent = new CoffeMakeFailedEvent(Guid.NewGuid(), Guid.NewGuid(), BusinessDateTime.UtcNow, sagaId);

            GridNode.Transport.Publish(_coffeMakeFailedEvent, new MessageMetadata(_coffeMakeFailedEvent.SourceId));

            //WaitFor<SagaTransitionEvent<SoftwareProgrammingSagaData>>();
            //WaitFor<SagaTransitionEvent<SoftwareProgrammingSagaData>>();
            Thread.Sleep(1000);
            _sagaDataAggregate = LoadAggregate <SagaDataAggregate <SoftwareProgrammingSagaData> >(sagaId);
        }
 public ISagaInstance <SoftwareProgrammingSaga, SoftwareProgrammingSagaData> Create(SagaDataAggregate <SoftwareProgrammingSagaData> message)
 {
     return(SagaInstance.New(new SoftwareProgrammingSaga(), message));
 }