Reply-channel on a <gateway/> is now optional. If absent, a temporary RendezvousChannel will be created for this particular invocation (default bevaviour of the underlying RequestReplyTemplate).
Also, a small fix for the corner case when a method like void doNothing() is called. In this case, nothing happens.
This commit is contained in:
Marius Bogoevici
2008-06-09 20:27:55 +00:00
parent f3d13ebf8f
commit 1d7d9046ae
2 changed files with 15 additions and 11 deletions

View File

@@ -147,7 +147,7 @@
<xsd:attribute name="id" type="xsd:ID" use="required"/>
<xsd:attribute name="service-interface" type="xsd:string" use="required"/>
<xsd:attribute name="request-channel" type="xsd:string"/>
<xsd:attribute name="reply-channel" type="xsd:string"/>
<xsd:attribute name="reply-channel" type="xsd:string" use="optional"/>
<xsd:attribute name="request-timeout" type="xsd:long"/>
<xsd:attribute name="reply-timeout" type="xsd:long"/>
<xsd:attribute name="message-mapper" type="xsd:string"/>
@@ -357,7 +357,7 @@
<xsd:attribute name="default-reply-channel" type="xsd:string" use="optional"/>
<xsd:attribute name="discard-channel" type="xsd:string" use="optional"/>
<xsd:attribute name="send-timeout" type="xsd:long" use="optional"/>
<xsd:attribute name="release-partial-sequences" type="xsd:boolean" use="optional"></xsd:attribute>
<xsd:attribute name="release-partial-sequences" type="xsd:boolean" use="optional"/>
<xsd:attribute name="send-partial-result-on-timeout" type="xsd:boolean" use="optional"/>
<xsd:attribute name="tracked-correlation-id-capacity" type="xsd:int" use="optional"/>
<xsd:attribute name="reaper-interval" type="xsd:long" use="optional"/>

View File

@@ -20,7 +20,6 @@ import java.lang.reflect.Method;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.aop.support.AopUtils;
import org.springframework.beans.SimpleTypeConverter;
@@ -121,22 +120,27 @@ public class GatewayProxyFactoryBean extends SimpleMessagingGateway
}
Method method = invocation.getMethod();
Class<?> returnType = method.getReturnType();
boolean shouldReturnMessage = Message.class.isAssignableFrom(returnType);
boolean isReturnTypeMessage = Message.class.isAssignableFrom(returnType);
boolean shouldReply = returnType != void.class;
int paramCount = method.getParameterTypes().length;
Object response = null;
if (paramCount == 0) {
if (shouldReturnMessage) {
return this.receive();
if (shouldReply) {
if (isReturnTypeMessage) {
return this.receive();
}
response = this.receive();
}
response = this.receive();
}
else {
Object payload = (paramCount == 1) ? invocation.getArguments()[0] : invocation.getArguments();
if (returnType.equals(void.class)) {
this.send(payload);
return null;
if (shouldReply) {
response = isReturnTypeMessage ? this.sendAndReceiveMessage(payload) : this.sendAndReceive(payload);
}
else {
this.send(payload);
response = null;
}
response = shouldReturnMessage ? this.sendAndReceiveMessage(payload) : this.sendAndReceive(payload);
}
return (response != null) ? this.typeConverter.convertIfNecessary(response, returnType) : null;
}