lbv*_*rgo 6 methods integration gateway void spring-integration
我对SI网关功能有疑问/澄清:
如果我的网关接口定义如下:
public interface MyGateway{
public void myGatewayMethod(Message<?> inMessage);
}
Run Code Online (Sandbox Code Playgroud)
我的网关配置定义如下:
<int:gateway id="mySvcGateway"
service-interface="com.myCompany.myPkg.MyGateway"
error-channel="globalExceptionHandlerChannel">
<int:method name="myGatewayMethod" request-channel="myGatewayReqChannel" />
</int:gateway>
Run Code Online (Sandbox Code Playgroud)
我的问题/澄清是:
1)由于网关服务接口方法返回void,网关代理bean是否仍在"default-reply-channel"或用户定义的"reply-channel"上寻找响应?
2)换句话说,我还需要提及reply-channel="nullChannel"(或default-reply-channel="nullChannel")吗?
要么
由于方法返回无效,网关会自动理解不听取回复频道吗?
3)我是否仍然reply-timeout可以为此配置添加属性,或者它没有意义,因为没有预期的回复?
在类似的上下文中,如果我在服务接口方法中添加另一个方法,如下所示:
public interface MyGateway{
public void myGatewayMethod(Message<?> inMessage);
public Object myGatewayMethod2(Message<?> inMessage);
}
Run Code Online (Sandbox Code Playgroud)
并在我的网关配置中添加此方法,如下所示:
<int:gateway id="mySvcGateway"
service-interface="com.myCompany.myPkg.MyGateway"
error-channel="globalExceptionHandlerChannel">
<int:method name="myGatewayMethod" request-channel="myGatewayReqChannel" />
<int:method name="myGatewayMethod2" request-channel="myGatewayReqChannel2" />
</int:gateway>
Run Code Online (Sandbox Code Playgroud)
4)在这种情况下,我相信我需要定义reply-channel,更正?
5)default-reply-channel对于这种情况可能不起作用,因为一个方法网关期望响应而不是其他,正确吗?
6)如果是,那么对于返回void的方法,我是否需要明确提及reply-channel="nullChannel"?
谢谢确认.
拉利特!
感谢这么大的问题,我很惊讶所有这些问题都围绕着网关的void方法.
对所有这些人的快速合理答案是:
由于我们没有在参考手册中说明任何关于此事的内容,因此不必担心这样的配置,并且它应该按照
Spring Integration 的信念运行.
我开玩笑了,但每个笑话都有一部分真相.
现在让我们来看看源代码GatewayProxyFactoryBean:
private Object invokeGatewayMethod(MethodInvocation invocation, boolean runningOnCallerThread) throws Exception {
..........
boolean shouldReply = returnType != void.class;
..................
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;
}
Run Code Online (Sandbox Code Playgroud)
凡MessagingGatewaySupport.send()委托给
this.messagingTemplate.convertAndSend(requestChannel, object, this.historyWritingPostProcessor);
Run Code Online (Sandbox Code Playgroud)
这也是void,最后只是打电话MessageChannel.send().
正如你可能猜到此方法不关心replyChannel,并replyTimeout在所有.
从逻辑上讲,它假定这些选项将被忽略,而其他方法的void任何选项都default-*不会影响那些具有void返回类型的选项.
希望我很清楚.