title: Camel aggregator with correlationExpression
body: <p>I have an application written in camel 2.10.6 which uses the EIP <code>aggregator</code>. It receives as input 2 files: one ended with <code>-information</code> and the other ended with <code>-report</code>. I have to process both files (separately) and after processing I have to <i>combine</i> (i.e. <code>aggregate</code>) both together.</p>
  
  <p>For achieving this I am using the EIP  <code>aggregator</code>. 
  I have defined the routes using spring DSL. I do NOT have a correlation expression. That is, my expression is the constant <code>true</code>. </p>
  
  <pre><code>        &lt;route&gt;
          &lt;from uri="activemq:assemblingAll" /&gt;
          &lt;log message="\n----------&gt;&gt;&gt; @ASSEMBLEALL" /&gt;
  
          &lt;aggregate strategyRef="myAggregator" completionSize="2"&gt;
              &lt;correlationExpression&gt;
                  &lt;constant&gt;true&lt;/constant&gt;
              &lt;/correlationExpression&gt;
  
              &lt;to uri="activemq:toBeValidated" /&gt;
          &lt;/aggregate&gt;
      &lt;/route&gt;
  </code></pre>
  
  <p>I would like to <i>correlate</i> the files which belong together, that is, files with the <strong>same prefix</strong> (prefix is the string <i>before</I> <code>-information</code> (resp. <code>.report</code>). I believe that this would e also possible by setting some ID in the header. </p>
  
  <p>My problem is that I don't know how to do this. Up to now all my attempts have generated <code>org.apache.camel.CamelExchangeException: Invalid correlation key</code>.</p>
  
  <p>Any hint?</p>
  
  <p>Thanks in advance.</p>
  
  <p>My routes (simplified) looks as follows:</p>
  
  <pre><code>&lt;camelContext xmlns="http://camel.apache.org/schema/spring"&gt;
  
      &lt;!-- switchOnFilename" --&gt;
      &lt;route&gt;
          &lt;from uri="file:/inputdir" /&gt;
  
          &lt;choice&gt;
              &lt;when&gt;
                  &lt;simple&gt;${header.CamelFileName} regex '.*-information$'&lt;/simple&gt;
                  &lt;log message="\n----------&gt;&gt;&gt; -information" /&gt;
                  &lt;to uri="activemq:information" /&gt;
              &lt;/when&gt;
  
              &lt;otherwise&gt;
                  &lt;!-- The default case --&gt;
                  &lt;log message="\n----------&gt;&gt;&gt; DEFAULT CASE (*-report)" /&gt;
                  &lt;to uri="activemq:report" /&gt;
              &lt;/otherwise&gt;
          &lt;/choice&gt;
      &lt;/route&gt;
  
      &lt;route&gt;
          &lt;from uri="activemq:information" /&gt;
          &lt;bean ref="myExtractInformation" /&gt;
          &lt;to uri="xslt:ExtractInformation.xsl" /&gt;                    
          &lt;to uri="activemq:assemblingAll" /&gt;
      &lt;/route&gt;
  
      &lt;route&gt;
          &lt;from uri="activemq:report" /&gt;
          &lt;bean ref="myExtractReports" /&gt;         
          &lt;to uri="xslt:extractReports.xsl" /&gt;
          &lt;to uri="activemq:assemblingAll" /&gt;
      &lt;/route&gt;
  
      &lt;route&gt;
          &lt;from uri="activemq:assemblingAll" /&gt;
          &lt;log message="\n----------&gt;&gt;&gt; @ASSEMBLEALL" /&gt;
          &lt;aggregate strategyRef="myAggregator" completionSize="2"&gt;
              &lt;correlationExpression&gt;
                  &lt;constant&gt;true&lt;/constant&gt;
              &lt;/correlationExpression&gt;
  
              &lt;to uri="activemq:toBeValidated" /&gt;
          &lt;/aggregate&gt;
      &lt;/route&gt;
  
      &lt;route&gt;
          &lt;from uri="activemq:toBeValidated" /&gt;
  
          &lt;doTry&gt; 
              &lt;to uri="validator:validator.xsd" /&gt;
              &lt;to uri="activemq:insertUpdateDB" /&gt;
              &lt;doCatch&gt;
                  &lt;exception&gt;org.apache.camel.ValidationException&lt;/exception&gt;
                  &lt;log message="INVALID " /&gt;
  
                  &lt;to uri="mock:invalid" /&gt;
              &lt;/doCatch&gt;
              &lt;doFinally&gt;
                  &lt;log message="Finalizer...." /&gt;
                  &lt;to uri="mock:finally" /&gt;
                  &lt;to uri="mock:invalid" /&gt;
              &lt;/doFinally&gt;
          &lt;/doTry&gt;
      &lt;/route&gt;
  
      &lt;route&gt;
          &lt;from uri="activemq:insertUpdateDB" /&gt;
          &lt;setHeader headerName="CamelHttpMethod"&gt;
              &lt;constant&gt;PUT&lt;/constant&gt;
          &lt;/setHeader&gt;
          &lt;setHeader headerName="Content-Type" inheritErrorHandler="true" id="setHeader3"&gt;
              &lt;constant&gt;application/xml&lt;/constant&gt;
          &lt;/setHeader&gt;
          &lt;setHeader headerName="Content-Encoding"&gt;
              &lt;constant&gt;UTF-8&lt;/constant&gt;
          &lt;/setHeader&gt;
          &lt;to uri="http4://localhost:8181/rest/insertUpdateDB" /&gt;
      &lt;/route&gt;
  </code></pre>