Reputation: 1994
I have below camel route.
from("{{trade-publisher.trade-tnc.source-endpoint}}")
.doTry()
.bean(clientApi, "search(${body},${header.region})") //Returns List<Trade>
.split(simple("${body}"))
.parallelProcessing()
.doTry()
.bean(clientApi,"enrich(${body})") //Passing Trade Object
.endDoTry()
.doCatch(Exception.class)
.log(LoggingLevel.ERROR, "ENRICHMENT-EXCEPTION : ${exception.stacktrace}")
.end() //End of Inner try catch
.end()// End of split() and parallelProcessing()
.aggregate(aggegrationStrategy)
.exchange()
.completionTimeout(30000L)
...
...
But in my below aggregation I am getting List in newExchange
? Shouldn't it pass Trade
object instead List<Trade>
?
@Override
public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
Upvotes: 0
Views: 530
Reputation: 3665
At a guess, you have your aggregation at the wrong point in the route, assuming you want the aggregator to be called for each exchange produced by the splitter.
from("{{trade-publisher.trade-tnc.source-endpoint}}")
.doTry()
.bean(clientApi, "search(${body},${header.region})") //Returns List<Trade>
.split(simple("${body}"))
.parallelProcessing()
.aggregate(aggegrationStrategy) <-- MOVE AGGREGATOR INSIDE SPLIT
.completionTimeout(30000L)
.doTry()
.bean(clientApi,"enrich(${body})") //Passing Trade Object
.endDoTry()
.doCatch(Exception.class)
.log(LoggingLevel.ERROR, "ENRICHMENT-EXCEPTION : ${exception.stacktrace}")
.end() //End of Inner try catch
.end()// End of split() and parallelProcessing()
Upvotes: 0
Reputation: 7025
No, it is by design you get the List after the Splitter. See the Splitter EIP documentation and look for the paragraph What the Splitter returns
.
Since Camel 2.3 it returns the original message that was the input for the Splitter. If you want to do something with the individual parts, you have to do it inside the Splitter.
Well, you already do it in
.bean(clientApi,"enrich(${body})")
When you "close" the Splitter, you can continue to work with the original payload from before the Splitter. This can be very handy but if you don't need it, the route typically ends after the Splitter.
Upvotes: 2