Camel, end rest-based route, returning from choice in loop

143 views Asked by At

I'm trying to add error handling to my parallel processing:

...
.multicast(new GroupedMessageAggregationStrategy())
.parallelProcessing()
  .to("direct:getAndSaveRoute1")
  .to("direct:getAndSaveRoute2")
.end()
.split(body())
  .choice()
    .when(simple("${body.errorOcurred} == true"))
      //TODO:: end route returning current body
    .endChoice()
    .otherwise()
      .log(...)
    .endChoice()
  .end()
//after split, if no error occurred
.to("direct:nextRoute")
.end()

I can't seem to figure out though how to return/ end the route (and pass back the current body as the rest response body) within the choice in the split. end() and endRest() seem to cause issues...

It is also not clear as how many end()s I need; Adding an end() for the split causes an exception and makes Spring fail to boot.

1

There are 1 answers

0
Snappawapa On

For those in the future, I ended up making a bean to turn the list into a single message, and then do a choice based on that.

Not very 'camel', but needed to be wrapped up