title: How is Apache Camel's Enrich EIP Supposed to Work with File Endpoints?
body: <p>I am trying to learn how to use Apache Camel by writing simple routes that use the various EIPs. My mentor has suggested Apache ServiceMix as a good server for testing simple routes, so I'm using Apache ServiceMix 5.1.0. Currently, I'm trying to make a route that reads a request from a file, replaces the contents of the request with a response from a second file, and writes that response to a third file.</p>
  
  <p>Ideally, the second file wouldn't be deleted; I would eventually want to use this pattern in other self-tutorial routes, and the second file would mimic the response of a webservice. However, I'm just trying to get this to work right now, so I'm not complicating things with options like <code>noop</code>.</p>
  
  <p>If I've read <a href="http://camel.apache.org/content-enricher.html" rel="nofollow">the Apache Camel Wiki page for the Content Enricher</a> correctly, omitting the aggregation strategy from an <code>enrich</code> EIP will make Camel discard the contents of the message and replace it with the body obtained from the resource. So, I thought this Camel Route would do what I want:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
      xmlns:camel="http://camel.apache.org/schema/blueprint" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
         http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd"&gt;
  
      &lt;camelContext xmlns="http://camel.apache.org/schema/blueprint"&gt;
          &lt;route&gt;
              &lt;from uri="file:camel/inMessage/?fileName=replaceMe.txt" /&gt;
              &lt;enrich uri="file:camel/storedResponse/?fileName=withThis.txt" /&gt;
              &lt;to uri="file:camel/outMessage/?fileName=output.txt" /&gt;
          &lt;/route&gt;
      &lt;/camelContext&gt;
  
  &lt;/blueprint&gt;
  </code></pre>
  
  <p>What actually happens is that the contents of <code>camel/storedResponse/withThis.txt</code> is replaced with the contents of <code>camel/inMessage/replaceMe.txt</code>. The file <code>camel/outmessage/output.txt</code> is created, but it contains the contents of <code>replaceMe.txt</code>, not <code>withThis.txt</code>.</p>
  
  <p>Since I'm still new to Camel, I assume the problem is just me misreading something in the documentation, or overlooking an obvious configuration problem.</p>
  
  <p>For what it's worth, here are the contents of the files before starting the route.</p>
  
  <pre><code>replaceMe.txt
  This is the message sent. It should not appear in the response.
  
  withThis.txt
  This is the file stored in the server. The response should contain this text.
  
  output.txt does not yet exist.
  </code></pre>
  
  <p>Here are the contents of the files after the route has completed.</p>
  
  <pre><code>replaceMe.txt has been deleted.
  
  withThis.txt
  This is the message sent. It should not appear in the response.
  
  output.txt
  This is the message sent. It should not appear in the response.
  </code></pre>
  
  <p>Thank you for your time.</p>