/** * Invoke the method with the given message. * @param message the message. * @param providedArgs additional arguments. * @return the result of the invocation. * @throws Exception raised if no suitable argument resolver can be found, * or the method raised an exception. */ public InvocationResult invoke(Message<?> message, Object... providedArgs) throws Exception { // NOSONAR Class<? extends Object> payloadClass = message.getPayload().getClass(); InvocableHandlerMethod handler = getHandlerForPayload(payloadClass); Object result = handler.invoke(message, providedArgs); if (message.getHeaders().get(AmqpHeaders.REPLY_TO) == null) { Expression replyTo = this.handlerSendTo.get(handler); if (replyTo != null) { return new InvocationResult(result, replyTo, handler.getMethod().getGenericReturnType()); } } return new InvocationResult(result, null, handler.getMethod().getGenericReturnType()); }
/** * Invoke the method with the given message. * @param message the message. * @param providedArgs additional arguments. * @return the result of the invocation. * @throws Exception raised if no suitable argument resolver can be found, * or the method raised an exception. */ public InvocationResult invoke(Message<?> message, Object... providedArgs) throws Exception { // NOSONAR Class<? extends Object> payloadClass = message.getPayload().getClass(); InvocableHandlerMethod handler = getHandlerForPayload(payloadClass); Object result = handler.invoke(message, providedArgs); if (message.getHeaders().get(AmqpHeaders.REPLY_TO) == null) { Expression replyTo = this.handlerSendTo.get(handler); if (replyTo != null) { return new InvocationResult(result, replyTo, handler.getMethod().getGenericReturnType()); } } return new InvocationResult(result, null, handler.getMethod().getGenericReturnType()); }
public InvocationResult invoke(Message<?> message, Object... providedArgs) throws Exception { // NOSONAR if (this.invokerHandlerMethod != null) { return new InvocationResult(this.invokerHandlerMethod.invoke(message, providedArgs), null, this.invokerHandlerMethod.getMethod().getGenericReturnType()); } else if (this.delegatingHandler.hasDefaultHandler()) { // Needed to avoid returning raw Message which matches Object Object[] args = new Object[providedArgs.length + 1]; args[0] = message.getPayload(); System.arraycopy(providedArgs, 0, args, 1, providedArgs.length); return this.delegatingHandler.invoke(message, args); } else { return this.delegatingHandler.invoke(message, providedArgs); } }
public InvocationResult invoke(Message<?> message, Object... providedArgs) throws Exception { // NOSONAR if (this.invokerHandlerMethod != null) { return new InvocationResult(this.invokerHandlerMethod.invoke(message, providedArgs), null, this.invokerHandlerMethod.getMethod().getGenericReturnType()); } else if (this.delegatingHandler.hasDefaultHandler()) { // Needed to avoid returning raw Message which matches Object Object[] args = new Object[providedArgs.length + 1]; args[0] = message.getPayload(); System.arraycopy(providedArgs, 0, args, 1, providedArgs.length); return this.delegatingHandler.invoke(message, args); } else { return this.delegatingHandler.invoke(message, providedArgs); } }
private void returnOrThrow(org.springframework.amqp.core.Message amqpMessage, Channel channel, Message<?> message, Throwable throwableToReturn, Exception exceptionToThrow) throws Exception { // NOSONAR if (!this.returnExceptions) { throw exceptionToThrow; } try { handleResult(new InvocationResult(new RemoteInvocationResult(throwableToReturn), null, null), amqpMessage, channel, message); } catch (ReplyFailureException rfe) { if (void.class.equals(this.handlerAdapter.getReturnType(message.getPayload()))) { throw exceptionToThrow; } else { throw rfe; } } }
private void returnOrThrow(org.springframework.amqp.core.Message amqpMessage, Channel channel, Message<?> message, Throwable throwableToReturn, Exception exceptionToThrow) throws Exception { // NOSONAR if (!this.returnExceptions) { throw exceptionToThrow; } try { handleResult(new InvocationResult(new RemoteInvocationResult(throwableToReturn), null, null), amqpMessage, channel, message); } catch (ReplyFailureException rfe) { if (void.class.equals(this.handlerAdapter.getReturnType(message.getPayload()))) { throw exceptionToThrow; } else { throw rfe; } } }
private void asyncSuccess(InvocationResult resultArg, Message request, Channel channel, Object source, Object r) { doHandleResult(new InvocationResult(r, resultArg.getSendTo(), resultArg.getReturnType()), request, channel, source); try { channel.basicAck(request.getMessageProperties().getDeliveryTag(), false); } catch (IOException e) { this.logger.error("Failed to nack message", e); } }
private void asyncSuccess(InvocationResult resultArg, Message request, Channel channel, Object source, Object r) { doHandleResult(new InvocationResult(r, resultArg.getSendTo(), resultArg.getReturnType()), request, channel, source); try { channel.basicAck(request.getMessageProperties().getDeliveryTag(), false); } catch (IOException e) { this.logger.error("Failed to nack message", e); } }
Object errorResult = this.errorHandler.handleError(amqpMessage, message, e); if (errorResult != null) { handleResult(new InvocationResult(errorResult, null, null), amqpMessage, channel, message);
Object errorResult = this.errorHandler.handleError(amqpMessage, message, e); if (errorResult != null) { handleResult(new InvocationResult(errorResult, null, null), amqpMessage, channel, message);
Object result = invokeListenerMethod(methodName, listenerArguments, message); if (result != null) { handleResult(new InvocationResult(result, null, null), message, channel);
Object result = invokeListenerMethod(methodName, listenerArguments, message); if (result != null) { handleResult(new InvocationResult(result, null, null), message, channel);