camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d1x <>
Subject Apache Camel aggregate route with exception
Date Tue, 07 Feb 2017 15:11:50 GMT
I want to use Apache Camel parallel multicast to 3 routes and aggregate (and
wait for) 2 of them while leave 3rd go on its own (3rd one should not block
first two). I also need to process these two in "all" cases meaning that if
one of them fails (e.g. throws an exception during processing), it should be
aggregated as well.

>From what I understood from Camel documentation, that behavior should be
"default" as long as you don't specify say stopOnException. But what happens
is that exchange with exception never gets to my AggregationStrategy. What
is kind of weird is that processors behind aggregate get executed even when
there is completionSize(2).

So my question is: How is it possible that route after aggregation continues
without processing exchange with the exception in AggregationStrategy? And
how to solve my case correctly? Please note that doing .to("direct:sync") is
not that case because this exception may be thrown from the route that is
completely out of multicast-aggregate part of routes.

Here is the sample code (ExceptionThrowingProcessor throws MyException,
PropertySetterProcessor is not important):

CamelContext context = new DefaultCamelContext();
RouteBuilder builder = new RouteBuilder() {
    public void configure() throws Exception {

        .process(new PropertySetterProcessor("a", "onException"))

        .process(new PropertySetterProcessor("a", "before-multicast"))
        .to("direct:part1", "direct:part2", "direct:part3")

        .process(new PropertySetterProcessor("a", "part1"))

        .process(new PropertySetterProcessor("a", "part2"))
        .process(new ExceptionThrowingProcessor("oops")) // throws

        .process(new PropertySetterProcessor("a", "part3"));
// don't want this to be aggregated within direct:sync

        .aggregate(new TestAggregationStrategy())
        // strategy.aggregate is called only once (from part1) but not from
part2 :(
        .process(...this gets processed...)

Thanks in advance
Note that I also created StackOverflow thread if you want to get some
reputation there :-)

View this message in context:
Sent from the Camel - Users mailing list archive at

View raw message