title: Polling File Consumer In Apache
body: <p>I have started playing around with Apache camel recently. So being the experimental type I thought I would create a simple project that would scan a file directory every couple of seconds to see if I have a new file pick that file up and then copy it to another folder. Later on I want to place these files into a database.</p>
  
  <p>So keeping with the basics first I created a route such as the following:</p>
  
  <pre><code> from("file://c:/CTest/inbox?noop=true")
                  .to("file://C:/Ctest/outbox");
  </code></pre>
  
  <p>This worked and I thought ok lets add a timer. Initially I made the mistake of using a timer and trying this:</p>
  
  <pre><code>from("timer://myTimer?period=50").to("file://c:/CTest/inbox?noop=true")
                  .to("file://C:/Ctest/outbox");
  </code></pre>
  
  <p>I then had some strange exception about not being able to write a file. I then realised by placing the file route after the timer route it became a producer. So I researched a bit and here is where I am little confused.</p>
  
  <p>So from my understanding the file component uses the scheduled poll pattern. There is even a pollStrategy option in the file route url pattern. There is also a Polling Consumer EIP. </p>
  
  <p>So here is where my confusion sets in.</p>
  
  <p>1) If the file component uses the scheduled poll pattern does it use/implement the polling conumser EIP?</p>
  
  <p>2) How do I add a simple schedule to the file component to consume files say every 30 seconds?</p>
  
  <p>3) How do I create my own pollingStrategy by implementing org.apache.camel.PollingConsumerPollStrategy?</p>
  
  <p>I suspect I can do something like this:</p>
  
  <pre><code>    from("file://c:/CTest/inbox?noop=true&amp;pollStrategy=some-expression")
                  .to("file://C:/Ctest/outbox");
  </code></pre>
  
  <p>I have tried to get some examples around this but I am either not looking at the right places or missing the plot completely. I guess this is not so much a code related question but more of a what is the best strategy/pattern for this approach.</p>
  
  <p>Thanks
  Namphibian</p>