繁体   English   中英

Spring Integration Asyc流程

[英]Spring integration asyc flow

我对我的spring集成项目有一个要求,即在用户进行静息呼叫时需要提供状态,对此呼叫服务器进行一些处理n计算应重新调整的状态,如果状态为成功,那么我需要打电话给第三方服务,但这对用户是透明的(第三方应该是异步的)如何在Spring集成中实现

我希望您将<int-http:inbound-gateway>用于REST服务。

在这种情况下,您期望在TemporaryReplyChannel获得响应。

通常,透明地答复我们应该只使用标头中的该通道。

当未提供outputChannel时,所有Spring Integration请求-答复组件都将执行此outputChannel 真正应该有机地感觉到这一点:我们没有任何事情要做,因此将outputChannel的缺失视为流的结尾。 如果标题中有replyChannel ,我们会将结果发送回给调用者。 在您的情况下进入HTTP响应。

看起来现在已经适合您。

为了满足您的异步要求,我建议使用TaskExecutor类的PublishSubscribeChannel之类的PublishSubscribeChannel ,以便能够将相同的消息发送给多个订阅者,并以并行方式进行。

此事的XML配置看起来可能像这样:

<service-activator input-channel="lastProcessChannel" output-channel="3rdPartyChannel"/>

<publish-subscribe-channel id="3rdPartyChannel" task-executor="taskExecutor"/>

<bridge input-channel="3rdPartyChannel"/>

<service-activator input-channel="3rdPartyChannel"/>

独立于该executor<int-http:inbound-gateway>将等待答复,因此我们的async <bridge>将从另一个线程将结果生成到replyChannel也不会造成伤害。

您的第三方服务应从该<service-activator>调用,该<service-activator>是同一<publish-subscribe-channel>的第二个订阅<publish-subscribe-channel>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM