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); }
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")); }
private bool Execute(ReceiveTestCommand command) { if (!IsNew) { Emit(new TestReceivedEvent(command.SenderAggregateId, command.TestToReceive)); } else { TestErrors++; Throw(new TestedErrorEvent(TestErrors)); } return(true); }
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); } }
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); }
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())); }
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); }
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); }