Source:
private Object invokeGatewayMethod(MethodInvocation invocation, boolean runningOnCallerThread) throws Exception { if (!this.initialized) { this.afterPropertiesSet(); } Method method = invocation.getMethod(); MethodInvocationGateway gateway = this.gatewayMap.get(method); Class<?> returnType = method.getReturnType(); boolean shouldReturnMessage = Message.class.isAssignableFrom(returnType) || hasReturnParameterizedWithMessage(method, runningOnCallerThread); boolean shouldReply = returnType != void.class; int paramCount = method.getParameterTypes().length; Object response = null; @SuppressWarnings("deprecation") boolean hasPayloadExpression = method.isAnnotationPresent(org.springframework.integration.annotation.Payload.class) || method.isAnnotationPresent(Payload.class); if (!hasPayloadExpression && this.methodMetadataMap != null) { GatewayMethodMetadata metadata = this.methodMetadataMap.get(method.getName()); hasPayloadExpression = (metadata != null) && StringUtils.hasText(metadata.getPayloadExpression()); } if (paramCount == 0 && !hasPayloadExpression) { if (shouldReply) { if (shouldReturnMessage) { if (this.convertReceiveMessage) { return gateway.receive(); } else { MessageChannel replyChannel = gateway.getReplyChannel(); Assert.state(replyChannel != null && (replyChannel instanceof PollableChannel), "receive is not supported, because no pollable reply channel has been configured"); return gateway.messagingTemplate.receive(replyChannel); } } response = gateway.receive(); } } else { Object[] args = invocation.getArguments(); if (shouldReply) { response = shouldReturnMessage ? gateway.sendAndReceiveMessage(args) : gateway.sendAndReceive(args); } else { gateway.send(args); response = null; } } return (response != null) ? this.convert(response, returnType) : null; }

Target:
private Object invokeGatewayMethod(MethodInvocation invocation, boolean runningOnCallerThread) throws Exception { if (!this.initialized) { this.afterPropertiesSet(); } Method method = invocation.getMethod(); MethodInvocationGateway gateway = this.gatewayMap.get(method); Class<?> returnType = method.getReturnType(); boolean shouldReturnMessage = Message.class.isAssignableFrom(returnType) || hasReturnParameterizedWithMessage(method, runningOnCallerThread); boolean shouldReply = returnType != void.class; int paramCount = method.getParameterTypes().length; Object response = null; @SuppressWarnings("deprecation") boolean hasPayloadExpression = method.isAnnotationPresent(org.springframework.integration.annotation.Payload.class) || method.isAnnotationPresent(Payload.class); if (!hasPayloadExpression && this.methodMetadataMap != null) { GatewayMethodMetadata metadata = this.methodMetadataMap.get(method.getName()); hasPayloadExpression = (metadata != null) && StringUtils.hasText(metadata.getPayloadExpression()); } if (paramCount == 0 && !hasPayloadExpression) { if (shouldReply) { if (shouldReturnMessage) { if (this.convertReceiveMessage) { return gateway.receive(); } else { return gateway.receiveMessage(); } } response = gateway.receive(); } } else { Object[] args = invocation.getArguments(); if (shouldReply) { response = shouldReturnMessage ? gateway.sendAndReceiveMessage(args) : gateway.sendAndReceive(args); } else { gateway.send(args); response = null; } } return (response != null) ? this.convert(response, returnType) : null; }