我正在尝试向使用<recipient-list>
和自定义聚合器组合多个结果的入站 http 端点发出请求。如何让我的入站 http 端点“等待”自定义聚合器的结果?
这是我的示例流程。聚合器完美运行。但由于是异步的,入站 http 端点会立即返回。我真正想做的是从自定义聚合器返回结果作为对 http 端点的响应。我觉得我错过了一些简单的东西。
<flow name="AggregationExample">
<http:inbound-endpoint
exchange-pattern="request-response"
host="localhost"
port="8082"
path="test/aggregate"
/>
<recipient-list evaluator="groovy" expression="['vm://source1','vm://source2']"></recipient-list>
<!-- How do I wait for result of custom aggregator? -->
</flow>
<flow name="SourceAggregation">
<vm:inbound-endpoint path="sourceresult" />
<custom-aggregator failOnTimeout="true" class="com.example.MySourceAggregator"/>
<logger message="RESULTS: #[payload]"/>
</flow>
<flow name="Source1">
<vm:inbound-endpoint path="source1" />
<set-payload value="#[groovy:Thread.currentThread().getContextClassLoader().getResourceAsStream('example-source1.json').text]"/>
<vm:outbound-endpoint path="sourceresult" />
</flow>
<flow name="Source2">
<vm:inbound-endpoint path="source2" />
<set-payload value="#[groovy:Thread.currentThread().getContextClassLoader().getResourceAsStream('example-source2.json').text]"/>
<vm:outbound-endpoint path="sourceresult" />
</flow>