Ejemplo n.º 1
0
        public async Task Consume(ConsumeContext <RoutingSlipFaulted> context)
        {
            var request   = context.Message.GetVariable <TRequest>("Request");
            var requestId = context.Message.GetVariable <Guid>("RequestId");

            Uri faultAddress = null;

            if (context.Message.Variables.ContainsKey("FaultAddress"))
            {
                faultAddress = context.Message.GetVariable <Uri>("FaultAddress");
            }
            if (faultAddress == null && context.Message.Variables.ContainsKey("ResponseAddress"))
            {
                faultAddress = context.Message.GetVariable <Uri>("ResponseAddress");
            }

            if (faultAddress == null)
            {
                throw new ArgumentException($"The fault/response address could not be found for the faulted routing slip: {context.Message.TrackingNumber}");
            }

            var endpoint = await context.GetFaultEndpoint <TResponse>(faultAddress, requestId).ConfigureAwait(false);

            var response = await CreateFaultedResponseMessage(context, request, requestId);

            await endpoint.Send(response).ConfigureAwait(false);
        }