protected virtual void HandleMatch(T mapping, HandlerMethod handlerMethod, string lookupDestination, IMessage message)
        {
            handlerMethod = handlerMethod.CreateWithResolvedBean();
            var invocable = new InvocableHandlerMethod(handlerMethod);

            invocable.MessageMethodArgumentResolvers = MethodArgumentResolvers;
            try
            {
                var returnValue = invocable.Invoke(message);
                var returnType  = handlerMethod.ReturnType;
                if (returnType.ParameterType == typeof(void))
                {
                    return;
                }

                if (returnValue != null && MethodReturnValueHandlers.IsAsyncReturnValue(returnValue, returnType))
                {
                    var task = returnValue as Task;

                    throw new NotImplementedException("Async still todo");
                }
                else
                {
                    MethodReturnValueHandlers.HandleReturnValue(returnValue, returnType, message);
                }
            }
            catch (Exception ex)
            {
                Exception handlingException =
                    new MessageHandlingException(message, "Unexpected handler method invocation error", ex);
                ProcessHandlerMethodException(handlerMethod, handlingException, message);
            }
        }
示例#2
0
        public void TestMessagingException()
        {
            var cause = new MessageHandlingException(null, "test", new MessageHandlingException(null, "test", new InvalidCastException()));

            Assert.Throws <RabbitRejectAndDontRequeueException>(() => DoTest(cause));
        }