0
駱駝如何通過AggregateStrategy中的aggregate()返回多個呼叫。 我寫邏輯來聚合兩個csv文件,我想根據某些條件生成3個不同的文件,所以我想發送3個交換對象,我想將它發送到不同的路由器。駱駝如何在AggregateStrategy中通過聚合()返回多個呼叫
駱駝如何通過AggregateStrategy中的aggregate()返回多個呼叫。 我寫邏輯來聚合兩個csv文件,我想根據某些條件生成3個不同的文件,所以我想發送3個交換對象,我想將它發送到不同的路由器。駱駝如何在AggregateStrategy中通過聚合()返回多個呼叫
您實際上不能從聚合器返回多個交換。
但是,您可以根據您提及的情況,讓您的聚合器將所有CSV記錄返回Collection
,然後route將它們轉換爲三條不同的路線。
如果您願意,您可以在每條路線上彙總過濾的CSV記錄。
<route id="mainRoute">
<from ... />
<!-- this is you aggregator that aggregates the two CSV files' records -->
<aggregate strategyRef="aggregatorStrategy">
...
<!-- split the resulting records (aggregator returned an exchange with a List body)-->
<split>
<simple>${body}</simple>
<choice>
<when>
<!-- your condition here -->
<!-- send to the first category route -->
<to uri="direct:firstCategoryRecords" />
</when>
<when>
<!-- your condition here -->
<!-- send to the second category route -->
<to uri="direct:secondCategoryRecords" />
</when>
<!-- same for third category -->
...
</choice>
</split>
</aggregate>
</route>
<route id="firstCategoryRecordsRoute">
<from uri="direct:firstCategoryRecords" />
<!-- aggregate the filtered CSV records into one file here -->
...
</route>
<!-- rest of the routes -->
...
謝謝。 @Ahmad Y. Saleh。 – sekhar 2014-09-29 06:10:21