title: Camel "Composed Message Processor" how to detect "onComplete"
body: <p>In my camel route i have to use <a href="http://camel.apache.org/composed-message-processor.html" rel="nofollow">Composed Message Processor</a>. That means i first have to split the exchange (on big result set from db) and then i have to aggregate it.</p>
  
  <p>The problem i see by using the decoupled seda queue is how to detect that the work is done (the route is triggered manually, and will run for some hours ). I have to call back to the infrastructure that the work is done.</p>
  
  <p>Using "splitter only" variant is no good option because i would loose the aggreagator-correlation-logic (correlated exchanges must be in order). But the biggest problem is loosing the completionSize. I can't aggregate into multiple groups.</p>
  
  <p>Here is an example for the pattern:</p>
  
  <pre><code>from("direct:start")
      .split().body()
      .end()
      .to("seda:aggregate");
  
  // collect and re-assemble the validated OrderItems into an order again
  from("seda:aggregate")
      .process(setHeaders)
      .aggregate(new MyOrderAggregationStrategy()).header("orderId").completionSize(header("count"))
      .parallelProcessing()
      .process(doTheWork)
      .to("mock:result");
  </code></pre>
  
  <p>Here an example for splitter only:</p>
  
  <pre><code>from("direct:start")
      .routePolicy( finishNotifier ) //implements onExchangeDone
      .split(body(), new MyOrderStrategy())
      .parallelProcessing()
      .process(doTheWork)
      .to("bean:MyOrderService?method=buildCombinedResponse")
  </code></pre>
  
  <p>As a side note: just chaining split and aggregate only works if parallelProcessing is disabled. With enabled parallelProcessing "doTheWork" is called after finishNotifier.onExchangeDone. Since i call context.stop() if work finishes, "process" method were called after camel stopped!</p>