Spring 集成如何管理异步网关
How does Spring integration manages Async Gateway
我已经配置了下面的网关。这充当从部署在 tomcat 上的 Web 应用程序服务层到 SI 流的入口点。 invoke 方法将从服务层调用。 SI 流有许多组件,它使用拆分器、路由器和聚合器,最后将响应发送到 outputChannel。
在 SI 流程中,我使用任务执行器的数量让某些流程并行到 运行(特别是在拆分器之后)。
SI 如何确保 returns 正确响应服务层的调用?是否有可能将来自一个用户请求的响应发送到其他请求?如果是,是否需要任何特殊处理?如果需要,我可以粘贴完整配置。
<!-- Entry point Facade to DSL layer. To be called by Liquidity Portal web application -->
<int:gateway id="dslServiceFacade" service-interface="dsl.gateway.IDSLServiceFacade"
default-request-channel="inputChannel" default-reply-channel="outputChannel" error-channel="errorChannel" async-executor="dslParallelExecutor">
<int:method name="invoke" request-channel="inputChannel" request-timeout="5000"/>
</int:gateway>
public interface IDSLServiceFacade {
public Future<DSLResponseVO> invoke(Map<String, Object> requestMap) throws LSIntegrationException;
}
每个网关请求都会获得一个新的临时通道(在 replyChannel
header 中)。当您在网关上显式使用回复通道时,它会桥接到请求的实际回复通道。调用线程等待接收该通道上的回复。
一般来说,您可以省略回复通道,并且在最终端点上没有 output-channel
。该框架将检测到这一点并将回复直接路由到 replyChannel
header,返回到网关。
有时需要使用明确的回复渠道(例如,如果你想窃听它进行日志记录);在这些情况下,框架会执行我上面提到的桥接。
关键是replyChannel
header不被流量去掉;否则框架无法将回复返回给调用者。
我已经配置了下面的网关。这充当从部署在 tomcat 上的 Web 应用程序服务层到 SI 流的入口点。 invoke 方法将从服务层调用。 SI 流有许多组件,它使用拆分器、路由器和聚合器,最后将响应发送到 outputChannel。
在 SI 流程中,我使用任务执行器的数量让某些流程并行到 运行(特别是在拆分器之后)。
SI 如何确保 returns 正确响应服务层的调用?是否有可能将来自一个用户请求的响应发送到其他请求?如果是,是否需要任何特殊处理?如果需要,我可以粘贴完整配置。
<!-- Entry point Facade to DSL layer. To be called by Liquidity Portal web application -->
<int:gateway id="dslServiceFacade" service-interface="dsl.gateway.IDSLServiceFacade"
default-request-channel="inputChannel" default-reply-channel="outputChannel" error-channel="errorChannel" async-executor="dslParallelExecutor">
<int:method name="invoke" request-channel="inputChannel" request-timeout="5000"/>
</int:gateway>
public interface IDSLServiceFacade {
public Future<DSLResponseVO> invoke(Map<String, Object> requestMap) throws LSIntegrationException;
}
每个网关请求都会获得一个新的临时通道(在 replyChannel
header 中)。当您在网关上显式使用回复通道时,它会桥接到请求的实际回复通道。调用线程等待接收该通道上的回复。
一般来说,您可以省略回复通道,并且在最终端点上没有 output-channel
。该框架将检测到这一点并将回复直接路由到 replyChannel
header,返回到网关。
有时需要使用明确的回复渠道(例如,如果你想窃听它进行日志记录);在这些情况下,框架会执行我上面提到的桥接。
关键是replyChannel
header不被流量去掉;否则框架无法将回复返回给调用者。