Apache camel 在Camel 2.24中完成文件拆分后关闭所有聚合组

Apache camel 在Camel 2.24中完成文件拆分后关闭所有聚合组,apache-camel,spring-camel,apache-camel-3,Apache Camel,Spring Camel,Apache Camel 3,我有一个用例,可以逐行拆分文件,并根据某个键进行聚合,一旦文件中的所有记录完成拆分,就释放所有聚合的组。记录计数将是未知的,我想在camel 2.24版本中这样做 示例文件布局: { "key": "key1", "rec": "rec1" }, { "key": "key2", "rec": "rec2" }, { "key&

我有一个用例,可以逐行拆分文件,并根据某个键进行聚合,一旦文件中的所有记录完成拆分,就释放所有聚合的组。记录计数将是未知的,我想在camel 2.24版本中这样做

示例文件布局:

{
"key": "key1",
"rec": "rec1"
},
{
"key": "key2",
"rec": "rec2"
},
{
"key": "key1",
"rec": "rec3"
},
{
"key": "key2",
"rec": "rec4"
}
结果必须如下所示:

{
"key": "key1",
"rec": "rec1rec3"
},
{
"key": "key2",
"rec": "rec2rec4"
}
一旦处理了文件中的所有记录(拆分完成),则必须释放所有聚合组

此谓词单独释放最后一个聚合组(在本例中,仅释放了key2 group,而不是key1 group)。但我想释放聚合中的所有组。我知道从camel 2.9和3开始,有新的选项可用,并且它的所有工作都很好,因为我能够测试它。但我希望这可以通过camel 2.24版本实现,因为我无法将我的应用程序迁移到2.9或更高版本

解决方案可以是XML dsl或java代码,以关闭所有聚合组。有人能告诉我怎么处理吗

提前谢谢

    <route id="FileReadRoute">
        <from uri="file:///Users/project?noop=false&amp;idempotent=false&amp;delay=30s" />
        <split streaming="true">
            <tokenize token="\n"/>
            <setHeader headerName="keyData">
                <jsonpath>$.key</jsonpath>
            </setHeader>
            <to uri="direct:AggregatorflowStart" />
        </split>
    </route>

    <route id="route_Aggregator">
        <from uri="direct:AggregatorflowStart"/>
        <aggregate strategyRef="myAggregation" ignoreInvalidCorrelationKeys="true" completionTimeout="300000" >
             <correlationExpression><header>keyData</header></correlationExpression>
             <log message="After aggregation completion  = Sending out ${body}"/>
        </aggregate>
    </route>
public class myAggregation implements AggregationStrategy, Predicate {
    
    public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
        //usual logic to aggregateate the message   
    }
  
    @Override
    public boolean matches(Exchange exchange) {  
        return ((boolean) exchange.getProperty("CamelSplitComplete"));              
    }    
}