/// <summary> /// Processes the specified message asynchronously. /// </summary> /// <param name="message">The message.</param> /// <param name="context">Context for the message processing.</param> /// <param name="token"> The cancellation token.</param> /// <returns> /// The response promise. /// </returns> public Task<IMessage> ProcessAsync(IMessage message, IMessageProcessingContext context, CancellationToken token) { Contract.Requires(message != null); Contract.Ensures(Contract.Result<Task<IMessage>>() != null); return Contract.Result<Task<IMessage>>(); }
/// <summary> /// Interception called before invoking the handler to process the message. /// </summary> /// <param name="context">The processing context.</param> /// <param name="token">The cancellation token.</param> /// <returns> /// A task. /// </returns> public Task BeforeProcessAsync(IMessageProcessingContext context, CancellationToken token) { Contract.Requires(context != null); Contract.Ensures(Contract.Result<Task>() != null); return Contract.Result<Task>(); }
public Task Handle(object message, IMessageProcessingContext context) { ConsoleColor foregroundColor = Console.ForegroundColor; Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("The correlated saga could not be found. Have you configured the RavenDB.Bundle.UniqueConstrains on your RavenDB server?"); Console.ForegroundColor = foregroundColor; return Task.FromResult(0); }
/// <summary> /// Processes the specified message asynchronously. /// </summary> /// <param name="message">The message.</param> /// <param name="context">Context for the message processing.</param> /// <param name="token"> The cancellation token.</param> /// <returns> /// The response promise. /// </returns> public async Task<IMessage> ProcessAsync(IMessage message, IMessageProcessingContext context = null, CancellationToken token = default(CancellationToken)) { using (var messageHandler = this.CreateMessageHandler(message)) { if (context == null) { context = this.CreateProcessingContext(message, messageHandler); } else { context.Message = message; context.Handler = messageHandler; } var filters = this.GetOrderedFilters(context); try { foreach (var filter in filters) { await filter.BeforeProcessAsync(context, token); } var response = await messageHandler.ProcessAsync(message, context, token); context.Response = response; } catch (Exception ex) { context.Exception = ex; } foreach (var filter in filters.Reverse()) { await filter.AfterProcessAsync(context, token); } if (context.Exception != null) { throw context.Exception; } return context.Response; } }
public Task Handle(object message, IMessageProcessingContext context) { var sagaDisappearedMessage = new SagaDisappearedMessage(); return context.Reply(sagaDisappearedMessage); }
public Task Handle(object message, IMessageProcessingContext context) { Handled = true; return(TaskEx.CompletedTask); }
public Task Handle(object message, IMessageProcessingContext context) { return(null); }
public Task Handle(object message, IMessageProcessingContext context) { return(context.ForwardCurrentMessageTo("Samples.SagaMigration.Server.New")); }
public Task Handle(object message, IMessageProcessingContext context) { Context.SagaNotFound = true; return(Task.FromResult(0)); }
public Task Handle(object message, IMessageProcessingContext context) { TestContext.TimesFired++; return(Task.FromResult(0)); }
public Task HandleMessage(object message, IMessageProcessingContext context) { Calls.Add(DateTime.Now); throw new ApplicationException("This is an exception that should cause the message to be dead-lettered eventually."); }
public Task Handle(object message, IMessageProcessingContext context) { log.Error("The correlated saga could not be found. Is RavenDB.Bundle.UniqueConstrains configured on the RavenDB server?"); return(Task.FromResult(0)); }
public Task Handle(object message, IMessageProcessingContext context) { testContext.NotFoundHandlerCalled = true; return(Task.FromResult(0)); }
public Task Handle(object message, IMessageProcessingContext context) { log.Error("The correlated saga could not be found. Have you configured the RavenDB.Bundle.UniqueConstrains on your RavenDB server?"); return Task.FromResult(0); }
public Task Handle(object message, IMessageProcessingContext context) { var sagaDisappearedMessage = new SagaDisappearedMessage(); return(context.Reply(sagaDisappearedMessage)); }
public Task Handle(object message, IMessageProcessingContext context) { return null; }
/// <summary> /// Gets the ordered filters to be applied. /// </summary> /// <param name="context">The context.</param> /// <returns>An ordered list of filters which can be applied to the provided context.</returns> protected virtual IList<IMessageProcessingFilter> GetOrderedFilters(IMessageProcessingContext context) { Contract.Ensures(Contract.Result<IList<IMessageProcessingFilter>>() != null); var requestTypeInfo = context.Message.GetType().GetTypeInfo(); var behaviors = (from b in this.filterFactories where b.Metadata.MessageType.GetTypeInfo().IsAssignableFrom(requestTypeInfo) orderby b.Metadata.ProcessingPriority select b.CreateExport().Value).ToList(); // TODO optimize to cache the ordered filters/message type. return behaviors; }
public Task Handle(object message, IMessageProcessingContext context) { Handled = true; return TaskEx.CompletedTask; }
public async Task Handle(object message, IMessageProcessingContext context) { await context.Reply(new SagaDisappearedMessage()); }
public static string SafeGetMessageHeader(this IMessageProcessingContext context, string headerName) { return(context.MessageHeaders.ContainsKey(headerName) ? context.MessageHeaders[headerName] : null); }