Beispiel #1
0
        public Task Handle(IDomainEvent <TestAggregate, TestAggregateId, TestSentEvent> domainEvent)
        {
            if (IsNew)
            {
                var command = new ReceiveTestCommand(domainEvent.AggregateEvent.RecipientAggregateId,
                                                     domainEvent.AggregateIdentity, domainEvent.AggregateEvent.Test);

                Emit(new TestSagaStartedEvent(domainEvent.AggregateIdentity, domainEvent.AggregateEvent.RecipientAggregateId, domainEvent.AggregateEvent.Test));

                TestAggregateManager.Tell(command);
            }
            return(Task.CompletedTask);
        }
Beispiel #2
0
        public async Task <Result> Do(ReceiveTestCommand command)
        {
            if (!IsNew)
            {
                await Emit(new TestReceivedEvent(Id, command.SenderAggregateId, command.TestToReceive));

                return(Result.Success);
            }

            TestErrors++;
            await Emit(new TestedErrorEvent(Id, TestErrors));

            return(Result.Fail("TestedErrorEvent"));
        }
Beispiel #3
0
        private bool Execute(ReceiveTestCommand command)
        {
            if (!IsNew)
            {
                Emit(new TestReceivedEvent(command.SenderAggregateId, command.TestToReceive));
            }
            else
            {
                TestErrors++;
                Throw(new TestedErrorEvent(TestErrors));
            }

            return(true);
        }
Beispiel #4
0
        public async Task Handle(IDomainEvent <TestAggregateId, TestSentEvent> domainEvent)
        {
            if (IsNew)
            {
                var command = new ReceiveTestCommand(
                    domainEvent.AggregateEvent.RecipientAggregateId,
                    CommandId.New,
                    domainEvent.AggregateIdentity,
                    domainEvent.AggregateEvent.Test);

                Emit(new TestSagaStartedEvent(domainEvent.AggregateIdentity, domainEvent.AggregateEvent.RecipientAggregateId, domainEvent.AggregateEvent.Test));

                await PublishCommandAsync(command);
            }
        }
Beispiel #5
0
        private bool Handle(DomainEvent <TestAggregate, TestAggregateId, TestSentEvent> domainEvent)
        {
            if (IsNew)
            {
                var command = new ReceiveTestCommand(domainEvent.AggregateEvent.RecipientAggregateId,
                                                     domainEvent.AggregateIdentity, domainEvent.AggregateEvent.Test);

                Emit(new TestSagaStartedEvent(domainEvent.AggregateIdentity, domainEvent.AggregateEvent.RecipientAggregateId, domainEvent.AggregateEvent.Test));

                TestAggregateManager.Tell(command);

                return(true);
            }
            return(false);
        }
        private bool Execute(ReceiveTestCommand command)
        {
            if (!IsNew)
            {
                Emit(new TestReceivedEvent(command.SenderAggregateId, command.TestToReceive));
                Reply(TestExecutionResult.SucceededWith(command.SourceId));
            }
            else
            {
                TestErrors++;
                Throw(new TestedErrorEvent(TestErrors));
                Reply(TestExecutionResult.FailedWith(command.SourceId));
            }

            return(true);
        }
Beispiel #7
0
        public Task <IExecutionResult> Execute(ReceiveTestCommand command)
        {
            if (!IsNew)
            {
                Emit(new TestReceivedEvent(command.SenderAggregateId, command.TestToReceive));
                Reply(TestExecutionResult.SucceededWith(command.Metadata.SourceId));
            }
            else
            {
                TestErrors++;
                Throw(new TestedErrorEvent(TestErrors));
                ReplyFailure(TestExecutionResult.FailedWith(command.Metadata.SourceId));
            }

            return(Task.FromResult(ExecutionResult.Success()));
        }
Beispiel #8
0
        public Task HandleAsync(IDomainEvent <TestAggregate, TestAggregateId, TestSentEvent> domainEvent)
        {
            if (IsNew)
            {
                var command = new ReceiveTestCommand(
                    domainEvent.AggregateEvent.RecipientAggregateId,
                    CommandId.New,
                    domainEvent.AggregateIdentity,
                    domainEvent.AggregateEvent.Test);

                Emit(new TestAsyncSagaStartedEvent(domainEvent.AggregateIdentity, domainEvent.AggregateEvent.RecipientAggregateId, domainEvent.AggregateEvent.Test), new Metadata {
                    { "some-key", "some-value" }
                });

                TestAggregateManager.Tell(command);
            }

            return(Task.CompletedTask);
        }
Beispiel #9
0
        public bool Handle(IDomainEvent <TestAggregate, TestAggregateId, TestSentEvent> domainEvent)
        {
            if (IsNew)
            {
                var command = new ReceiveTestCommand(
                    domainEvent.AggregateEvent.RecipientAggregateId,
                    CommandId.New,
                    domainEvent.AggregateIdentity,
                    domainEvent.AggregateEvent.Test);

                RequestTimeout(new TestSagaTimeout("First timeout test"),
                               TimeSpan.FromSeconds(5));

                RequestTimeout(new TestSagaTimeout2("Second timeout test; handled asynchronously"),
                               TimeSpan.FromSeconds(10));

                Emit(new TestSagaStartedEvent(domainEvent.AggregateIdentity,
                                              domainEvent.AggregateEvent.RecipientAggregateId, domainEvent.AggregateEvent.Test));

                TestAggregateManager.Tell(command);
            }

            return(true);
        }