user1555190
user1555190

Reputation: 3233

Camel Using aggregation and completing on dynamic completion size

Hi I have a camel route that splits an incoming message, i then want to aggregate this message, but i dont know how many messages will be split.

i have used the following:

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

this doesnt work, and it hangs... however if i set the completion size toa numerical value it works.

Anyone any ideas how to dynamically aggregate, and wait for completion. by the way the header is set before the split.

Upvotes: 1

Views: 3264

Answers (1)

burki
burki

Reputation: 7005

You do not need an aggregator nor a completion size for this. You simply need a Splitter EIP with an aggregation strategy.

In the linked example you can see that such a Splitter does a re-aggregation of whatever it has splitted before. No matter how much parts were resulting from the split.

// 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

Upvotes: 1

Related Questions