1
我正在嘗試向使用<recipient-list>
和自定義聚合器合併多個結果的入站http端點發出請求。如何讓我的入站http端點「等待」自定義聚合器的結果?具有請求響應交換模式的Mule自定義聚合器
這裏是我的示例流程。聚合器完美運作。但由於是異步的,入站http端點立即返回。我真正想做的是從Custom Aggregator返回結果作爲對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>
這兩個文件只是一個更復雜的查找過程的演示。同樣,收件人列表也不是靜態的,而是演示的一部分。我能夠通過添加請求回覆來實現我所需要的。謝謝! – Jeff