【发布时间】:2022-07-06 04:09:13
【问题描述】:
我正在研究 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>
但是,我已经在聚合器中指定了输出通道。 下面是一个例外,即使我在标题中添加回复通道,应用程序也会使用 stackoverflow。 org.springframework.messaging.core.DestinationResolutionException:没有可用的输出通道或回复通道标头 在 org.springframework.integration.handler.AbstractMessageProducingHandler.sendOutput(AbstractMessageProducingHandler.java:452) ~[spring-integration-core-5.5.13.jar:5.5.13] 在 org.springframework.integration.handler.AbstractMessageProducingHandler.doProduceOutput(AbstractMessageProducingHandler.java:325) ~[spring-integration-core-5.5.13.jar:5.5.13] 在 org.springframework.integration.handler.AbstractMessageProducingHandler.produceOutput(AbstractMessageProducingHandler.java:268) ~[spring-integration-core-5.5.13.jar:5.5.13] 在 org.springframework.integration.handler.AbstractMessageProducingHandler.sendOutputs(AbstractMessageProducingHandler.java:232) ~[spring-integration-core-5.5.13.jar:5.5.13]
【问题讨论】:
-
可能你
fetchTransformer返回一个Message不是基于请求… -
@ArtemBilan 我可以看到汇总数据。但是,一旦 processAggregator 被返回,它会再次调用 AbstractMessageProducingHandler 中的produceOutput。不知道为什么。我在这里有什么遗漏吗
-
请展示一下你的变压器在做什么
-
outputChannel订阅者是什么? -
@ArtemBilan 你是对的。我正在修改变压器中的标题。我认为这就是我遇到问题的原因。我避免修改标题。现在它正在工作。谢谢
标签: spring-integration spring-integration-dsl spring-integration-http