public async Task Invoke(MessageContext messageContext) { var pipelineStartedAt = DateTime.UtcNow; using (var childBuilder = builder.CreateChildBuilder()) { var message = new IncomingMessage(messageContext.MessageId, messageContext.Headers, messageContext.Body); var rootContext = pipelineComponent.CreateRootContext(childBuilder, messageContext.Extensions); var transportReceiveContext = new TransportReceiveContext(message, messageContext.TransportTransaction, messageContext.ReceiveCancellationTokenSource, rootContext); try { await transportReceiveContext.InvokePipeline <ITransportReceiveContext>().ConfigureAwait(false); } catch (Exception e) { e.Data.Add("Message ID", message.MessageId); if (message.NativeMessageId != message.MessageId) { e.Data.Add("Transport message ID", message.NativeMessageId); } throw; } await transportReceiveContext.RaiseNotification(new ReceivePipelineCompleted(message, pipelineStartedAt, DateTime.UtcNow)).ConfigureAwait(false); } }
public async Task Invoke(MessageContext messageContext, CancellationToken cancellationToken = default) { var pipelineStartedAt = DateTimeOffset.UtcNow; using (var childScope = rootBuilder.CreateScope()) { var message = new IncomingMessage(messageContext.NativeMessageId, messageContext.Headers, messageContext.Body); var rootContext = new RootContext(childScope.ServiceProvider, messageOperations, pipelineCache, cancellationToken); rootContext.Extensions.Merge(messageContext.Extensions); var transportReceiveContext = new TransportReceiveContext(message, messageContext.TransportTransaction, rootContext); try { await receivePipeline.Invoke(transportReceiveContext).ConfigureAwait(false); } catch (Exception e) { e.Data["Message ID"] = message.MessageId; if (message.NativeMessageId != message.MessageId) { e.Data["Transport message ID"] = message.NativeMessageId; } throw; } await receivePipelineNotification.Raise(new ReceivePipelineCompleted(message, pipelineStartedAt, DateTimeOffset.UtcNow), cancellationToken).ConfigureAwait(false); } }
public async Task Invoke(MessageContext messageContext) { var pipelineStartedAt = DateTime.UtcNow; using (var childBuilder = builder.CreateChildBuilder()) { var rootContext = new RootContext(childBuilder, pipelineCache, eventAggregator); var message = new IncomingMessage(messageContext.MessageId, messageContext.Headers, messageContext.Body); var context = new TransportReceiveContext(message, messageContext.TransportTransaction, messageContext.ReceiveCancellationTokenSource, rootContext); context.Extensions.Merge(messageContext.Extensions); await mainPipeline.Invoke(context).ConfigureAwait(false); await context.RaiseNotification(new ReceivePipelineCompleted(message, pipelineStartedAt, DateTime.UtcNow)).ConfigureAwait(false); } }
public async Task Invoke(MessageContext messageContext) { var pipelineStartedAt = DateTime.UtcNow; using (var childBuilder = builder.CreateChildBuilder()) { var rootContext = new RootContext(childBuilder, pipelineCache, eventAggregator); var message = new IncomingMessage(messageContext.MessageId, messageContext.Headers, messageContext.Body); var context = new TransportReceiveContext(message, messageContext.TransportTransaction, messageContext.ReceiveCancellationTokenSource, rootContext); context.Extensions.Merge(messageContext.Context); await mainPipeline.Invoke(context).ConfigureAwait(false); await context.RaiseNotification(new ReceivePipelineCompleted(message, pipelineStartedAt, DateTime.UtcNow)).ConfigureAwait(false); } }
public async Task Invoke(MessageContext messageContext, CancellationToken cancellationToken = default) { var pipelineStartedAt = DateTimeOffset.UtcNow; using (var childScope = rootBuilder.CreateScope()) { var message = new IncomingMessage(messageContext.NativeMessageId, messageContext.Headers, messageContext.Body); var rootContext = new RootContext(childScope.ServiceProvider, messageOperations, pipelineCache, cancellationToken); rootContext.Extensions.Merge(messageContext.Extensions); var transportReceiveContext = new TransportReceiveContext(message, messageContext.TransportTransaction, rootContext); try { await receivePipeline.Invoke(transportReceiveContext).ConfigureAwait(false); } #pragma warning disable PS0019 // Do not catch Exception without considering OperationCanceledException - enriching and rethrowing catch (Exception ex) #pragma warning restore PS0019 // Do not catch Exception without considering OperationCanceledException { ex.Data["Message ID"] = message.MessageId; if (message.NativeMessageId != message.MessageId) { ex.Data["Transport message ID"] = message.NativeMessageId; } ex.Data["Pipeline canceled"] = transportReceiveContext.CancellationToken.IsCancellationRequested; throw; } await receivePipelineNotification.Raise(new ReceivePipelineCompleted(message, pipelineStartedAt, DateTimeOffset.UtcNow), cancellationToken).ConfigureAwait(false); } }