骆驼使用聚合并完成动态完成大小

时间:2018-06-20 14:58:22

标签: java apache-camel

嗨,我有一条骆驼路线,用于拆分传入的邮件,然后我想汇总此邮件,但我不知道将拆分多少邮件。

我使用了以下内容:

.aggregate(new AggregateStrategy()).header("uuid").completionSize(header("CamelSplitSize"))

这不起作用,并且挂起了...但是,如果我将补全大小设置为一个数值,则可以起作用。

任何人如何动态聚合,并等待完成。通过在拆分之前设置标头的方式。

1 个答案:

答案 0 :(得分:1)

不需要聚合器或完成大小。您只需要一个Splitter EIP with an aggregation strategy

在链接的示例中,您可以看到,这样的拆分器会对其之前拆分的内容进行重新聚合。无论拆分产生了多少部分。

// a Splitter with an AggregationStrategy
.split([yourSplitCriteria], new MyAggregationStrategy())
    // each splitted message part is sent to this bean 
    .to("bean:PartProcessor")
    // you can do whatever you want in here
    // end the split to re-aggregate the message parts
.end()
// here, after the split-ending you get the re-aggregated messages