protected override void OnMessageReceived(object sender, BaseMessage e) { if (e is MiddlewareRequest) { ExecuteAsync(e as MiddlewareRequest).ConfigureAwait(false); } else if (e is MiddlewareResponse) { ExecuteNextAsync(e as MiddlewareResponse).ConfigureAwait(false); } else { var exception = new Exception("Bad Message: Message needs to be Middleware Request"); var middlewareException = new MiddlewareException(exception) { Id = Guid.NewGuid(), CreatedOn = DateTime.UtcNow, ErrorMessages = new List <string>() { exception.Message }, PipelineId = this.Id, TimeTaken = TimeSpan.Zero, ExecutionId = this.CorrelationId, Message = exception.ToString() }; AbortAsync(middlewareException).Wait(); } }
protected virtual void OnMessageReceived(object sender, BaseMessage e) { var request = e as MiddlewareRequest; if (request == null) { var exception = new Exception("Bad Message: Message needs to be Middleware Request"); var middlewareException = new MiddlewareException(exception) { Id = Guid.NewGuid(), CreatedOn = DateTime.UtcNow, ErrorMessages = new List <string>() { exception.Message }, MiddlewareId = this.Id, PipelineId = EnvironmentConfiguration.ContainsKey("PipelineId") ? EnvironmentConfiguration["PipelineId"].ToString() : string.Empty, TimeTaken = TimeSpan.Zero, ExecutionId = this.ExecutionId, Message = exception.ToString() }; AbortAsync(middlewareException).Wait(); } ExecuteAsync(request); }
private Event Convert(MiddlewareException exception) { var @event = new Event() { Payload = _converter.Serialize(exception), CreatedOn = exception.CreatedOn, Id = exception.Id.ToString(), PartitionKey = exception.PipelineId, ContentType = typeof(MiddlewareException).FullName, Properties = new Dictionary <string, object>(exception.ExecutionConfiguration) }; return(@event); }
private Message Convert(MiddlewareException exception) { var message = new Message() { Id = exception.Id.ToString(), Payload = _converter.Serialize(exception), Properties = new Dictionary <string, object>(exception.ExecutionConfiguration), FilterCorrelation = exception.PipelineId, IsControl = false, ContentType = typeof(MiddlewareException).FullName }; return(message); }
public virtual async Task AbortAsync(MiddlewareException exception) { await Outbox.SendMessage(exception); }
public Task InvokeAsync(TestContext context, MiddlewareException <TestContext> exception, RequestDelegate <TestContext> next) { context.CatchN += context.N; context.CatchedException = exception; return(next(context)); }