当前位置: 首页 > 知识库问答 >
问题:

来自收件人列表路由器的异步呼叫

贲永思
2023-03-14

我对SI是个新手,但现在已经读了很多书了。我必须从flow再打一个电话,那已经实现了。我需要这个调用是不阻塞的,这样链就不会等待它的执行-它被发送到另一个系统,可能是关闭的。

我需要向2个通道发送一条消息,所以我不带任何条件地使用了收件人-列表-路由器。

<int:recipient-list-router id="processEngineRouter" input-channel="newApplicationChannel">
    <int:recipient channel="finishFlowChannel"/>
    <int:recipient channel="processEngineChannel"/>
</int:recipient-list-router>

FinishFlowChannel完成后,将调用ProcessEngineChannel。这很好,但问题是,输入NewApplicationChannel也会等待ProcessEngineChannel完成,即使我使用的是Executor通道也应该是异步的。

<int:channel id="finishFlowChannel"/>
<int:chain input-channel="finishFlowChannel" output-channel="apiReplyChannel">
    <!-- create response -->
    <int:transformer ref="xxToYYTransformer"/>
</int:chain>

<int:channel id="processEngineChannel">
    <int:dispatcher task-executor="taskExecutor"/>
</int:channel>
<int:chain input-channel="processEngineChannel">

    <!-- transform x to y -->
    <int:transformer ref="xToYTransformer"/>

    <!-- call PE -->
    <int:gateway request-channel="peRCh"/>
</int:chain>

,其中task前缀来自http://www.springframework.org/schema/task/spring-task.xsd 3.1版,没有其他设置。

路由器的输入通道为

<int:channel id="newApplicationChannel"/>
<int:channel id="naRequestChannel"/>
<int:chain input-channel="naRequestChannel" output-channel="newApplicationChannel">

    <int:transformer>
        ...
    </int:transformer>

    <si-xml:unmarshalling-transformer unmarshaller="xxMarshaller"/>

    <!-- enrich header with necessary data -->
    <int:header-enricher>
        ...
    </int:header-enricher>

    <!-- transform xx to yy -->
    <int:transformer ref="xxToYyTransformer"/>

    <!-- call yyy service -->
    <int:gateway request-channel="yyyServiceRequestChannel"/>

</int:chain>

当我将delayer添加到链中时,它起到了作用,但这不是一个很好的解决方案。

我的问题是,我是否错误地使用了taskExecutor?我还可以如何使调用异步?我不想使用队列,因为我不需要重复轮询事件。

http-apr-8080-exec-2 14:39:23,530 DEBUG DirectChannel:224 - preSend on channel 'apiRequestChannel'
http-apr-8080-exec-2 14:39:23,534 DEBUG MessageHandlerChain:67 - org.springframework.integration.handler.MessageHandlerChain#4
http-apr-8080-exec-2 14:39:23,535 DEBUG MessageTransformingHandler:67 - org.springframework.integration.transformer.MessageTransformingHandler#4ac5c32e
http-apr-8080-exec-2 14:39:23,557 DEBUG MessageTransformingHandler:156 - handler 'org.springframework.integration.transformer.MessageTransformingHandler#4ac5c32e' sending reply 
http-apr-8080-exec-2 14:39:23,557 DEBUG HeaderValueRouter:67 - (inner bean)#16 received message: 
http-apr-8080-exec-2 14:39:23,558 DEBUG DirectChannel:224 - preSend on channel 'naRequestChannel', message: 
http-apr-8080-exec-2 14:39:23,558 DEBUG MessageHandlerChain:67 - org.springframework.integration.handler.MessageHandlerChain#33 received message: 
http-apr-8080-exec-2 14:39:23,558 DEBUG MessageTransformingHandler:67 - org.springframework.integration.transformer.MessageTransformingHandler@3cbcf04e received message: 
http-apr-8080-exec-2 14:39:23,565 DEBUG MessageTransformingHandler:156 - handler 'org.springframework.integration.transformer.MessageTransformingHandler@3cbcf04e' sending reply 
http-apr-8080-exec-2 14:39:23,566 DEBUG MessageTransformingHandler:67 - org.springframework.integration.transformer.MessageTransformingHandler#6a5c2445 received message: 
http-apr-8080-exec-2 14:39:23,594 DEBUG MessageTransformingHandler:156 - handler 'org.springframework.integration.transformer.MessageTransformingHandler#6a5c2445' sending reply 
http-apr-8080-exec-2 14:39:23,595 DEBUG MessageTransformingHandler:67 - org.springframework.integration.transformer.MessageTransformingHandler#47516490 received message: 
http-apr-8080-exec-2 14:39:23,596 DEBUG MessageTransformingHandler:156 - handler 'org.springframework.integration.transformer.MessageTransformingHandler#47516490' sending reply 
http-apr-8080-exec-2 14:39:23,596 DEBUG MessageTransformingHandler:67 - org.springframework.integration.transformer.MessageTransformingHandler@2342f67d received message: 
http-apr-8080-exec-2 14:39:23,597 DEBUG MessageTransformingHandler:156 - handler 'org.springframework.integration.transformer.MessageTransformingHandler@2342f67d' sending reply 
http-apr-8080-exec-2 14:39:23,598 DEBUG RequestReplyMessageHandlerAdapter:67 - (inner bean)#231 received message: 
http-apr-8080-exec-2 14:39:23,600 DEBUG DirectChannel:224 - preSend on channel 'dossierAddEventRequestChannel', message: 
http-apr-8080-exec-2 14:39:23,601 DEBUG PayloadTypeRouter:67 - (inner bean)#250 received message: 
http-apr-8080-exec-2 14:39:23,602 DEBUG DirectChannel:224 - preSend on channel 'dossierAddEventRequestGenericChannel', message: 
http-apr-8080-exec-2 14:39:23,602 DEBUG MessageHandlerChain:67 - org.springframework.integration.handler.MessageHandlerChain#41 received message: 
http-apr-8080-exec-2 14:39:23,603 DEBUG MessageTransformingHandler:67 - org.springframework.integration.transformer.MessageTransformingHandler#23bdb02e received message: http-apr-8080-exec-2 14:39:23,603 DEBUG MessageTransformingHandler:156 - handler 'org.springframework.integration.transformer.MessageTransformingHandler#23bdb02e' sending reply http-apr-8080-exec-2 14:39:23,604 DEBUG MessageTransformingHandler:67 - org.springframework.integration.transformer.MessageTransformingHandler@54054c41 received message: http-apr-8080-exec-2 14:39:23,606 DEBUG MessageTransformingHandler:156 - handler 'org.springframework.integration.transformer.MessageTransformingHandler@54054c41' sending reply http-apr-8080-exec-2 14:39:23,606 DEBUG DirectChannel:237 - postSend (sent=true) on channel 'dossierAddEventRequestGenericChannel', message: http-apr-8080-exec-2 14:39:23,607 DEBUG DirectChannel:237 - postSend (sent=true) on channel 'dossierAddEventRequestChannel', message: 
http-apr-8080-exec-2 14:39:23,607 DEBUG GatewayProxyFactoryBean:134 - Unable to attempt conversion of Message payload types. Component 'org.springframework.integration.gateway.GatewayProxyFactoryBean#2e29d50d' has no explicit ConversionService reference, and there is no 'integrationConversionService' bean within the context.
http-apr-8080-exec-2 14:39:23,608 DEBUG RequestReplyMessageHandlerAdapter:156 - handler '(inner bean)#231' sending reply Message: http-apr-8080-exec-2 14:39:23,608 DEBUG MessageTransformingHandler:67 - org.springframework.integration.transformer.MessageTransformingHandler@3f03c0ad received message: 
http-apr-8080-exec-2 14:39:23,609 DEBUG MessageTransformingHandler:156 - handler 'org.springframework.integration.transformer.MessageTransformingHandler@3f03c0ad' sending reply http-apr-8080-exec-2 14:39:23,611 DEBUG RequestReplyMessageHandlerAdapter:67 - (inner bean)#232 received message: http-apr-8080-exec-2 14:39:23,612 DEBUG DirectChannel:224 - preSend http-apr-8080-exec-2 14:39:23,612 DEBUG ServiceActivatingHandler:67 - ServiceActivator for [org.springframework.integration.handler.MethodInvokingMessageProcessor@4149888e] received http-apr-8080-exec-2 14:39:23,614 DEBUG DirectChannel:224 - preSend on channel 'dossierServiceRequestRouter', message: http-apr-8080-exec-2 14:39:23,614 DEBUG PayloadTypeRouter:67 - (inner bean)#17 received message: 
http-apr-8080-exec-2 14:39:23,615 DEBUG DirectChannel:224 - preSend on channel 'dossierServiceJaxbRequestChannel', message: http-apr-8080-exec-2 14:39:23,616 DEBUG MessageHandlerChain:67 - org.springframework.integration.handler.MessageHandlerChain#5 received message: 
http-apr-8080-exec-2 14:39:23,616 DEBUG MessageTransformingHandler:67 - org.springframework.integration.transformer.MessageTransformingHandler#7d8e9adf received message: http-apr-8080-exec-2 14:39:23,634 DEBUG MessageTransformingHandler:156 - handler 'org.springframework.integration.transformer.MessageTransformingHandler#7d8e9adf' sending reply http-apr-8080-exec-2 14:39:23,635 DEBUG RequestReplyMessageHandlerAdapter:67 - (inner bean)#18 received message: [Payload=[#document: null]][Headers={timestamp=1372768763634, http-apr-8080-exec-2 14:39:23,636 DEBUG DirectChannel:224 - preSend on channel 'dossierServiceDocumentRequestChannel', message: 
http-apr-8080-exec-2 14:39:23,636 DEBUG SimpleWebServiceOutboundGateway:67 - org.springframework.integration.ws.SimpleWebServiceOutboundGateway#0 received message: http-apr-8080-exec-2 14:39:24,206 DEBUG DirectChannel:237 - postSend (sent=true) on channel 'dossierServiceDocumentRequestChannel', message: [Payload=[#document: null]][Headers={timestamp=1372768763636, id=a193877c-0faf-4573-b6b4-97ca3cd25f66, errorChannel=org.springframework.integration.core.MessagingTemplate$TemporaryReplyChannel@3875c597, xp_dossierEvent_operator_username=afs-process, xp_dossierEvent_name=NewApplication, replyChannel=org.springframework.integration.core.MessagingTemplate$TemporaryReplyChannel@3875c597, xp_dossierEvent_dateTime=2013-07-02T14:39:23, xp_dossierEvent_details=Nieuwe aanvraag aangemaakt, xp_dossierEvent_operator_name=AFS Proces, xp_endUser=nl.vwpfs.pos.bpf.EndUser@598ef578, xp_businessFunctionName=NewApplication}]
http-apr-8080-exec-2 14:39:24,206 DEBUG GatewayProxyFactoryBean:134 - Unable to attempt conversion of Message payload types. Component 'org.springframework.integration.gateway.GatewayProxyFactoryBean#1d59e6df' has no explicit ConversionService reference, and there is no 'integrationConversionService' bean within the context.
http-apr-8080-exec-2 14:39:24,207 DEBUG RequestReplyMessageHandlerAdapter:156 - handler '(inner bean)#18' sending reply Message: 
http-apr-8080-exec-2 14:39:24,207 DEBUG MessageTransformingHandler:67 - org.springframework.integration.transformer.MessageTransformingHandler#79444986 received message: http-apr-8080-exec-2 14:39:24,218 DEBUG MessageTransformingHandler:156 - handler 'org.springframework.integration.transformer.MessageTransformingHandler#79444986' sending reply http-apr-8080-exec-2 14:39:24,219 DEBUG DirectChannel:237 - postSend (sent=true) on channel 'dossierServiceJaxbRequestChannel', message: http-apr-8080-exec-2 14:39:24,219 DEBUG DirectChannel:237 - postSend (sent=true) on channel 'dossierServiceRequestRouter', message: 
http-apr-8080-exec-2 14:39:24,219 DEBUG GatewayProxyFactoryBean:134 - Unable to attempt conversion of Message payload types. Component 'dossierServiceGateway' has no explicit ConversionService reference, and there is no 'integrationConversionService' bean within the context.
http-apr-8080-exec-2 14:39:24,220 DEBUG ServiceActivatingHandler:156 - handler 'ServiceActivator for http-apr-8080-exec-2 14:39:24,220 DEBUG GatewayProxyFactoryBean:134 - Unable to attempt conversion of Message payload types. Component 'org.springframework.integration.gateway.GatewayProxyFactoryBean#5e970110' has no explicit ConversionService reference, and there is no 'integrationConversionService' bean within the context.
http-apr-8080-exec-2 14:39:24,221 DEBUG RequestReplyMessageHandlerAdapter:156 - handler '(inner bean)#232' sending reply Message: http-apr-8080-exec-2 14:39:24,221 DEBUG DirectChannel:224 - preSend on channel 'newApplicationChannel', message: 
http-apr-8080-exec-2 14:39:24,221 DEBUG RecipientListRouter:67 - org.springframework.integration.router.RecipientListRouter#0 received message: http-apr-8080-exec-2 14:39:24,222 DEBUG DirectChannel:224 - preSend on channel 'finishFlowChannel', message: http-apr-8080-exec-2 14:39:24,222 DEBUG MessageHandlerChain:67 - org.springframework.integration.handler.MessageHandlerChain#35 received message: [Payload=nl.vwpfs.pos.xmlcdm.dossier.service.CreateDossierResponse@6b37695c
http-apr-8080-exec-2 14:39:24,222 DEBUG MessageTransformingHandler:67 - org.springframework.integration.transformer.MessageTransformingHandler@57316e85 received message: http-apr-8080-exec-2 14:39:24,223 DEBUG MessageTransformingHandler:156 - handler 'org.springframework.integration.transformer.MessageTransformingHandler@57316e85' sending reply http-apr-8080-exec-2 14:39:24,224 DEBUG DirectChannel:224 - preSend on channel 'apiReplyChannel', message: http-apr-8080-exec-2 14:39:24,224 DEBUG MessageTransformingHandler:67 - http-apr-8080-exec-2 14:39:24,235 DEBUG DirectChannel:237 - postSend (sent=true) on channel 'apiReplyChannel', message: http-apr-8080-exec-2 14:39:24,236 DEBUG DirectChannel:237 - postSend (sent=true) on channel 'finishFlowChannel', message: 
http-apr-8080-exec-2 14:39:24,236 DEBUG ExecutorChannel:224 - preSend on channel 'processEngineChannel', message: 
http-apr-8080-exec-2 14:39:24,239 DEBUG ExecutorChannel:237 - postSend (sent=true) on channel 'processEngineChannel', message: 
taskExecutor-1 14:39:24,239 DEBUG MessageHandlerChain:67 - org.springframework.integration.handler.MessageHandlerChain#34 received message: 
http-apr-8080-exec-2 14:39:24,239 DEBUG DirectChannel:237 - postSend (sent=true) on channel 'newApplicationChannel', message: 
taskExecutor-1 14:39:24,240 DEBUG MessageTransformingHandler:67 - org.springframework.integration.transformer.MessageTransformingHandler@289f6ae received message: 
http-apr-8080-exec-2 14:39:24,240 DEBUG DirectChannel:237 - postSend (sent=true) on channel 'naRequestChannel', message: 
http-apr-8080-exec-2 14:39:24,241 DEBUG DirectChannel:237 - postSend (sent=true) on channel 'apiRequestChannel', message: 
taskExecutor-1 14:39:27,817 DEBUG MessageTransformingHandler:156 - handler 'org.springframework.integration.transformer.MessageTransformingHandler@289f6ae' sending reply Message: 
taskExecutor-1 14:39:27,819 DEBUG RequestReplyMessageHandlerAdapter:67 - (inner bean)#235 received message: 
taskExecutor-1 14:39:27,822 DEBUG DirectChannel:224 - preSend on channel 'sendToProcessEngineChannel', message: 
taskExecutor-1 14:39:27,822 DEBUG MarshallingWebServiceOutboundGateway:67 - org.springframework.integration.ws.MarshallingWebServiceOutboundGateway#0 received message: 
taskExecutor-1 14:39:28,094 DEBUG MarshallingWebServiceOutboundGateway:156 - handler 'org.springframework.integration.ws.MarshallingWebServiceOutboundGateway#0' sending reply 
taskExecutor-1 14:39:28,095 DEBUG DirectChannel:237 - postSend (sent=true) on channel 'sendToProcessEngineChannel', message: 
taskExecutor-1 14:39:28,095 DEBUG GatewayProxyFactoryBean:134 - Unable to attempt conversion of Message payload types. Component 'org.springframework.integration.gateway.GatewayProxyFactoryBean#762589c3' has no explicit ConversionService reference, and there is no 'integrationConversionService' bean within the context.
taskExecutor-1 14:39:28,095 DEBUG RequestReplyMessageHandlerAdapter:156 - handler '(inner bean)#235' sending reply Message: 

共有1个答案

阎宾实
2023-03-14

一切正常...

...
http-apr-8080-exec-2 14:39:24,224 DEBUG DirectChannel:224 - preSend on channel 'apiReplyChannel', message: 
http-apr-8080-exec-2 14:39:24,224 DEBUG MessageTransformingHandler:67 - 
http-apr-8080-exec-2 14:39:24,235 DEBUG DirectChannel:237 - postSend (sent=true) on channel 'apiReplyChannel', message: 
http-apr-8080-exec-2 14:39:24,236 DEBUG DirectChannel:237 - postSend (sent=true) on channel 'finishFlowChannel', message: 
http-apr-8080-exec-2 14:39:24,236 DEBUG ExecutorChannel:224 - preSend on channel 'processEngineChannel', message: 
http-apr-8080-exec-2 14:39:24,239 DEBUG ExecutorChannel:237 - postSend (sent=true) on channel 'processEngineChannel', message: 
taskExecutor-1 14:39:24,239 DEBUG MessageHandlerChain:67 - org.springframework.integration.handler.MessageHandlerChain#34 received message: 
http-apr-8080-exec-2 14:39:24,239 DEBUG DirectChannel:237 - postSend (sent=true) on channel 'newApplicationChannel', message: 
taskExecutor-1 14:39:24,240 DEBUG MessageTransformingHandler:67 - org.springframework.integration.transformer.MessageTransformingHandler@289f6ae received message: 
http-apr-8080-exec-2 14:39:24,240 DEBUG DirectChannel:237 - postSend (sent=true) on channel 'naRequestChannel', message: 
http-apr-8080-exec-2 14:39:24,241 DEBUG DirectChannel:237 - postSend (sent=true) on channel 'apiRequestChannel', message: 
taskExecutor-1 14:39:27,817 DEBUG MessageTransformingHandler:156 - handler 'org.springframework.integration.transformer.MessageTransformingHandler@289f6ae' sending reply Message: 
...

如您所见,...exec-2线程在APIReplyChannel上发送应答,然后在ProcessEngineChannel上发送(preSend和postSend是背靠背的),并移交给线程TaskExecutor-1,然后它开始处理该通道链、转换器等上的流。

...exec-2线程继续完成其工作(以APIRequestChannel上的postSend结束)。

但是,我看到您在processEngineChannel链上没有输出通道-框架将尝试将该回复发送到消息的replychannel头中的任何内容-如果您想放弃该回复,应该将链的output-channel设置为nullchannel。

 类似资料:
  • 我是spring Integration的新手。在spring integration的配置中,我有: 在CSVEntreprise类中,我用布尔返回定义了方法,我希望当它返回true时使用通道channel1_3TRUE,当它返回false时使用通道channel1_3FALSE?

  • 英文原文: http://emberjs.com/guides/routing/asynchronous-routing/ 本节内容主要介绍一些路由的高级特性,以及路由是如何处理应用中的一些复杂异步逻辑的。 承诺简介 Ember在路由中处理异步逻辑的方案主要依赖于承诺(Promise)。简单地说,承诺就是代表了最后的值的对象。承诺可以被履行(成功的获得了最后的结果)也可以被拒绝(没有获得最后的结果

  • Ember.js路由器能够使用异步路由处理应用程序中的复杂异步逻辑。 下面给出的表显示了路由器中处理异步逻辑的不同类型 - S.No. 异步路由器和描述 1 路由器暂停承诺 可以通过从模型钩子返回promise来暂停转换。 2 当Promises拒绝 如果在转换期间模型拒绝承诺,则将中止转换。 3 Recovering from Rejection 从中止的过渡中恢复。

  • 问题内容: Angular在路由上不提供任何授权/访问权限(我说的是默认的Angular路由1.x,而不是beta 2.0或UI路由)。但是我必须执行它。 我遇到的问题是我有一项服务,该服务调用服务器以提供此信息并返回承诺。但是,此数据仅获取一次,然后缓存在客户端上,但是仍然需要获取一次。 我现在想处理检查下一条路由是否定义了特定属性的事件。然后,该处理程序应使用我前面提到的服务获取该数据,并根据

  • 我的任务是简单地制作一个控制器,当它们准备好时立即给我结果(下面的简单示例) 我想得到字符串的确切数量(例如1000个字符串,以某种方式为1秒)(实际上我需要得到func的结果,但为了简化任务,只是字符串) 因此,当我在控制器中收到一些请求时,我希望它能以这种方式在它们准备好后尽快给出答案(无需缓冲结果): 1秒钟 “一些绳子”- 1秒钟 “另一个”- 1秒钟 “第三个”- 1000秒 “一些绳子

  • 问题内容: 我正在尝试创建一个书签,单击后将向用户请求一些信息(本例中为url和其他几个字段),然后将该数据发送到服务器上的php页面,然后显示结果。 我想为此进行Ajax调用,以便实际上不重定向到新页面,仅获取数据,但我想我会遇到Ajax的“相同来源策略”限制…。基本上做同一件事的已知方法? 另外,传递参数的最佳方法是什么?我已经有一种机制可以将参数作为表单中的发布消息接收…有什么办法可以重用呢