处理多个HTTP出站网关



我正在研究spring集成http。想要进行多个http调用并收集对一个公共java对象的响应。我正面临一个问题,说没有输出/回复通道在聚合器的末尾。这是xml定义

<int:channel id="intermediateWChannel">
<int:interceptors>
<int:wire-tap channel="intermediateWLogger" />
</int:interceptors>
</int:channel>
<int:channel id="intermediateSChannel">
<int:interceptors>
<int:wire-tap channel="intermediateSLogger" />
</int:interceptors>
</int:channel>
<int:logging-channel-adapter id="intermediateWLogger" expression="'Fetch Wtms Trip : '.concat(payload)" level="INFO" />
<int:logging-channel-adapter id="intermediateSLogger" level="INFO" />
<int:chain input-channel="intermediateSChannel" output-channel="publishsubscribechannel">
<int-http:outbound-gateway 
id="outboundGateway"
url="{url2}"
http-method="GET" 
request-factory="requestFactory"
charset="UTF-8"
mapped-request-headers="Accept:application/json"
expected-response-type="java.lang.String"></int-http:outbound-gateway>
<int:object-to-json-transformer/>
</int:chain>
<int:chain id="chain2" input-channel="publishsubscribechannel" output-channel="aggregatorChannel">
<int:transformer ref="fetchTransformer" method="process" />
</int:chain>
<int:chain id="request-chain" input-channel="publishsubscribechannel" output-channel="aggregatorChannel">
<int-http:outbound-gateway 
id="strideOutboundGateway1"
url="url3"
http-method="GET" 
request-factory="requestFactory"
charset="UTF-8"
mapped-request-headers="Accept:application/json"
expected-response-type="java.lang.String"></int-http:outbound-gateway>
<int:transformer ref="fetchTransformer" method="process1" />
</int:chain>
<int:chain id="chain3" input-channel="aggregatorChannel" output-channel="outputChannel">
<int:aggregator id="tAggregator" 
ref="tDataAggregator"
method="processAggregator"
correlation-strategy-expression="headers['id']" 
release-strategy="aggregatorReleaseStrategy" 
expire-groups-upon-completion="true"/>
</int:chain>

但是,我已经在聚合器中指定了输出通道。下面是一个例外,即使我在header中添加了回复通道,应用程序还是会使用stackoverflow。destinationresolutionexception:没有输出通道或回复通道标头可用[springframework.integration.handler. abstractmessageproducinghandler . sendoutput] [spring-integration-core-5.5.13.jar:5.5.13](AbstractMessageProducingHandler.java:325) ~[spring-integration-core-5.5.13.jar:5.5.13](AbstractMessageProducingHandler.java:268) ~[spring-integration-core-5.5.13.jar:5.5.13][spring-integration-core-5.5.13.jar:5.5.13]

变压器与其他端点不同,它不修改我们从其方法调用返回的Message。它被视为转换器对应答消息创建具有完全控制。因此,如果需要保留一些请求消息头,建议使用MessageBuilder.copyHeadersIfAbsent()API。这样在请求-应答场景中,必要的replyChannel标头出现在应答消息中。

我们可能不得不在docs: https://docs.spring.io/spring-integration/docs/current/reference/html/message-transformation.html#messaging-transformation-chapter中提到变压器的shouldCopyRequestHeaders()行为。请随意提出GH问题。

相关内容

  • 没有找到相关文章

最新更新