public async Task Evaluate() { var builder = CreateRoutingSlipBuilder(_routingSlip); Build(builder); var routingSlip = builder.Build(); await _publisher.PublishRoutingSlipActivityCompensated(_compensateContext.ActivityName, _compensateContext.ExecutionId, _compensateContext.Timestamp, _duration, _routingSlip.Variables, _compensateLog.Data).ConfigureAwait(false); if (HasMoreCompensations(routingSlip)) { var endpoint = await _compensateContext.GetSendEndpoint(routingSlip.GetNextCompensateAddress()).ConfigureAwait(false); await _compensateContext.Forward(endpoint, routingSlip).ConfigureAwait(false); } else { var faultedTimestamp = _compensateContext.Timestamp + _duration; var faultedDuration = faultedTimestamp - _routingSlip.CreateTimestamp; await _publisher.PublishRoutingSlipFaulted(faultedTimestamp, faultedDuration, _routingSlip.Variables, _routingSlip.ActivityExceptions.ToArray()).ConfigureAwait(false); } }
public async Task <CompensationResult> Compensate(CompensateContext <TakeProductLog> context) { logger.LogInformation($"Compensate Take Product Courier called for order {context.Log.OrderId}"); var uri = QueueNames.GetMessageUri(nameof(ReturnProductTransactionMessage)); var sendEndpoint = await context.GetSendEndpoint(uri); await sendEndpoint.Send <ReturnProductTransactionMessage>(new { ProductBaskets = context.Log.Baskets }); return(context.Compensated()); }
public async Task <CompensationResult> Compensate(CompensateContext <PaymentLog> context) { logger.LogInformation($"Payment copmensated Courier called for customer {context.Log.CustomerId}"); var uri = QueueNames.GetMessageUri(nameof(ReturnCustomerCreditMessage)); var sendEndpoint = await context.GetSendEndpoint(uri); await sendEndpoint.Send <ReturnCustomerCreditMessage>(new { Credit = context.Log.Credit, CustomerId = context.Log.CustomerId }); return(context.Compensated()); }
Task <ISendEndpoint> ISendEndpointProvider.GetSendEndpoint(Uri address) { return(_context.GetSendEndpoint(address)); }