public async Task HandleAsync(IMessageContext<StartSaga> context, CancellationToken cancellationToken = default) { _logger.LogInformation($"processing saga '{context.Message.CorrelationId}'..."); var message = new MySagaCompleted(Guid.NewGuid(), context.Message.CorrelationId); this.Publish(message); }
public async Task CompensateAsync(ICompensationContext <StartSaga> context, CancellationToken cancellationToken = default) { _logger.LogWarning($"saga '{context.MessageContext.Message.CorrelationId}' failed! Reason: {context.Exception.Message}"); this.State.CurrentStep = MySagaState.Steps.Failed; var message = new MySagaCompleted(Guid.NewGuid(), context.MessageContext.Message.CorrelationId); await this.Bus.PublishAsync(message, cancellationToken); }
public async Task HandleAsync(IMessageContext <StartSaga> context, CancellationToken cancellationToken = default) { _logger.LogInformation($"processing saga '{context.Message.CorrelationId}'..."); if (_maxFailuresCount-- > 0) { throw new ApplicationException("whoops!"); } var message = new MySagaCompleted(Guid.NewGuid(), context.Message.CorrelationId); this.Publish(message); }
public async Task HandleAsync(IMessageContext <StartSaga> context, CancellationToken cancellationToken = default) { _logger.LogInformation($"starting saga '{context.Message.CorrelationId}'..."); if (context.Message.WillFail) { throw new ApplicationException("something, somewhere, went terribly, terribly wrong."); } this.State.CurrentStep = MySagaState.Steps.Successful; var message = new MySagaCompleted(Guid.NewGuid(), context.Message.CorrelationId); await this.Bus.PublishAsync(message, cancellationToken); }