public void BusConfigurationError(IMessage msg, MissingHandlerException ex, string name) { LogName.LogError(ex, $"({name}) Can't handle message {msg}"); var item = Get <MessageProcessingAudit>(msg); if (item == null) { return; } item.ThrewConfigurationError = true; }
public override TResponse Dispatch <TResponse>(TDispatchable dispatchable) { Type queryType = dispatchable.GetType(); Type responseType = typeof(TResponse); Func <KeyValuePair <Tuple <Type, Type>, IHandler>, bool> matchingHandler = k => k.Key.Item1 == queryType && k.Key.Item2 == responseType; if (!TypedHandlers.Any(matchingHandler)) { MissingHandlerException exception = (MissingHandlerException)typeof(MissingHandlerException) .GetMethod("For") .MakeGenericMethod(queryType, responseType) .Invoke(null, null); throw exception; } IHandler candidate = TypedHandlers.First(matchingHandler).Value; Type handlerInterfaceSpecificType = typeof(IHandler <,>).MakeGenericType(queryType, responseType); var type = candidate.GetType(); var @interface = type.GetInterfaces().First(i => i.FullName == handlerInterfaceSpecificType.FullName); var tryHandle = @interface.GetMethod("TryHandle", new Type[] { queryType }); return((TResponse)tryHandle.Invoke(candidate, new object[] { dispatchable })); }
public void MessageCantBeHandled(IMessage msg, MissingHandlerException ex) { }