Exemplo n.º 1
0
        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;
        }
Exemplo n.º 2
0
        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 }));
        }
Exemplo n.º 3
0
 public void MessageCantBeHandled(IMessage msg, MissingHandlerException ex)
 {
 }