春季集成 - 需要在后端中使用异步处理的Web服务网关的立即响应



我们有一个要求外部客户端调用我们的Spring Integration Inbound WebService网关之一,我们需要立即以通用的OK状态确认它们。同时,有效载荷将提交到异步处理的频道,我们不需要响应(电子邮件将根据某些业务验证发送)。

我们尝试使用异步网关和执行器频道(带有任务执行程序),但无法弄清楚如何使网关立即响应。两种情况下,它都是一种单方面的Web服务,没有任何响应。

配置:

<context:component-scan base-package="com.myapp.springintegration" />

<channel id="helloWorldRequestChannel">
    <dispatcher task-executor="taskExecutor"/>
</channel>
<channel id="helloWorldReplyChannel"/>
<task:executor id="taskExecutor" pool-size="2"/>
<gateway id="helloServiceGateway" 
 service-interface="com.myapp.springintegration.HelloService"
 default-request-channel="helloWorldRequestChannel" default-reply-channel="helloWorldReplyChannel"/>
 <service-activator input-channel="helloWorldRequestChannel" ref="helloServiceImpl" method="hello" />

我看不到任何<int-ws:inbound-gateway>,但可能会这样实现要求:

<int-ws:inbound-gateway request-channel="requestChannel"/>
<int:recipient-list-router input-channel="requestChannel">
    <int:recipient channel="response" />
    <int:recipient channel="process" />
</int:recipient-list-router>
<int:transformer input-channel="response" expression="'OK'"/>
<int:channel id="process">
   <int:dispatcher task-executor="testExecutor"/>
</int:channel>

您将请求发送到recipient-list-router,该请求将您的消息分发给其他两个频道。第一个(response)只是立即返回简单回复WS。第二个(process)将消息转移到单独的Thread,因此该通道的订户将执行其工作,而不会阻止WS Thread

希望我能清楚。

相关内容

最新更新