title: Apache Camel split and aggregate exception handling
body: <p>We defined a route in Camel with split and aggregate functionality, but can't propagate the exception back to split after the aggregator. Which cause's the split to run even if we encounter an exception</p>
  
  <p>below is the code which is not working </p>
  
  <pre><code>from("direct:MyRoute")
       .routeId("MyRouteID")
          .split().tokenize("\n", 1)
          .streaming().stopOnException()
          .choice()
          .when(simple("${property.CamelSplitIndex} &gt; 0"))
             .unmarshal(domainDataFormat)
             .choice()
             .when(simple("${property.CamelSplitComplete}"))
             .process(
                new Processor()
                {
                   @Override
                   public void process(Exchange exchange) throws Exception
                   {
                      exchange.getIn().getHeaders().put(Exchange.AGGREGATION_COMPLETE_ALL_GROUPS_INCLUSIVE, true);
                   }
                }
             )
             .end()
             .aggregate(myAggregationStrategy).constant(true) //if i comment this line split will be stop on exception
             .threads().executorService(executorService)
             .process(myProcessor).end()
       .end();
  </code></pre>
  
  <p>Processor(myProcessor) from the above code is below:</p>
  
  <pre><code>counter.incrementAndGet(); //atomic counter 
  if(counter.get()==3)
    {
       exchange.setException(new RuntimeException());
       throw new RuntimeCamelException();
    }
  </code></pre>
  
  <p>But, the moment I remove the aggregate from the route, Split is able to stop the route on Exception.</p>