コード例 #1
0
        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);
            }
        }
コード例 #2
0
        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());
        }
コード例 #3
0
        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());
        }
コード例 #4
0
 Task <ISendEndpoint> ISendEndpointProvider.GetSendEndpoint(Uri address)
 {
     return(_context.GetSendEndpoint(address));
 }