title: Apache Camel: using stream and onCompletion
body: <p>I have a route that needs to download one file, via HTTP.</p>
  
  <p>This route is dynamically added when a message containing a command (containing the URL of HTTP resource, and URI of local file where to save it) is received, and then when the file transfer is completed I want to remove the route, thus using Camel only as a protocol translator.</p>
  
  <p>I'm using Camel for this because this route falls into a project built on EIPs, where Camel is used everywhere for messaging and integration.</p>
  
  <p>I used:</p>
  
  <pre><code>onCompletion().setBody(simple("")).bean(new Stop(getContext(), transferID));
  
  from("stream:url?url="+from).to("stream:file?fileName="+to).routeId(this.transferID);
  </code></pre>
  
  <p>(file is big, 10-100 Gb)</p>
  
  <p>I see that <code>onCompletion</code> fires before the whole file transfers, actually it transfers only a non-predictable quantity of bytes, like 100-300 kB.</p>
  
  <p>Are "stream" and <code>onCompletion</code> not compatible or am I doing something wrong?</p>
  
  <p>EDIT: in the Bean I'm doing:</p>
  
  <pre><code>c.stopRoute(transferID);
  c.removeRoute(transferID);
  </code></pre>