protected virtual async Task GenerateFault <T>(ConsumeContext <T> context, Exception exception) where T : class { if (context.ReceiveContext.PublishFaults || context.FaultAddress != null || context.ResponseAddress != null) { Fault <T> fault = new FaultEvent <T>(context.Message, context.MessageId, HostMetadataCache.Host, exception, context.SupportedMessageTypes.ToArray()); var faultPipe = new FaultPipe <T>(context); var faultEndpoint = context.ReceiveContext is InMemoryOutboxReceiveContext ? await this.GetFaultEndpoint <T>().ConfigureAwait(false) : await context.GetFaultEndpoint <T>().ConfigureAwait(false); await faultEndpoint.Send(fault, faultPipe, CancellationToken).ConfigureAwait(false); } }
protected virtual async Task GenerateFault <T>(ConsumeContext <T> context, Exception exception) where T : class { if (context.ReceiveContext.PublishFaults || context.FaultAddress != null || context.ResponseAddress != null) { Fault <T> fault = new FaultEvent <T>(context.Message, context.MessageId, HostMetadataCache.Host, exception, context.SupportedMessageTypes.ToArray()); var faultPipe = new FaultPipe <T>(context); ConsumeContext faultContext = context; while (faultContext.TryGetPayload <InMemoryOutboxConsumeContext>(out var outboxConsumeContext)) { faultContext = outboxConsumeContext.CapturedContext; } var faultEndpoint = await faultContext.GetFaultEndpoint <T>().ConfigureAwait(false); await faultEndpoint.Send(fault, faultPipe, CancellationToken).ConfigureAwait(false); } }