Take the 2-minute tour ×

I am trying to read all the text files in a ftp directory, parse them. If the parsing is successful, then move them to a different directory(not the default one i.e. .done directory) and if the parsing fails then file should remain in the ftp directory. The concept looks simple but then my route only reads a single file from ftp and routes ends itself after fetching one file.

Following is the code:

    public void configure() throws Exception {

         from(EndPointConstants.DIRECT + GetDriverProductInfo.class.getSimpleName())  

Is it something related to pollEnrich that its only able to get a single file and the process is not happening recursively?

share|improve this question
add comment

1 Answer


Use something like this example:


From the Camel Documentation (FTP/SFTP/FTPS Component):


So You can use for example:





I think you should come up with something like this (the following code) as pollEnrich() doesn't suite for this case.

(The following code is highly discouraged to be used as it is rather than an example of use)

    .process(new Processor()
        public void process(Exchange exchange) throws Exception
            ConsumerTemplate consumerTemplate = exchange.getContext().createConsumerTemplate();
            ProducerTemplate producerTemplate = exchange.getContext().createProducerTemplate();


share|improve this answer
Thanks for the resolution but the problem is something else. I want all the files in FTP folder to be consumed by a single route. Currently above code just fetches one file and stops the route. I want to fetch all the files in a single go from FTP and then iterate through the list of files in route. Any help would be appreciated. –  user1692063 Sep 24 '12 at 7:51
You should consume from ftp then, eg from(ftp), then it polls all the files. pollEnrich is for polling a single message. –  Claus Ibsen Sep 24 '12 at 8:27
as @ClausIbsen said. You might want to use .from(..) and add an aggregation policy camel.apache.org/aggregator.html . There is also an option for ftp to iterate through the ftp directory. –  Evalon Sep 24 '12 at 8:36
Thanks @ClausIbsen and Bagos but this doesnt solve my problem either. Earlier I was trying to use .from(ftp) but the problem is that in dev env, we are running the route from junits by using ProducerTemplate.sendBody("Test") and configuring uri by pointing to the route. In this case my first from() is the direct: and second is .from(ftp) as shown below. Running this particular route doesnt hit the ftp and body only contains by what its been set in the junit. Code is in the following comment. What can be done to resolve this issue. –  user1692063 Sep 24 '12 at 9:30
@Override public void configure() throws Exception { from(EndPointConstants.DIRECT + this.getClass().getSimpleName()) .from("ingestion_user@*******&recursive=true") .to(ProductFTPURLHelper.getPath()); } –  user1692063 Sep 24 '12 at 9:31
show 1 more comment

Your Answer


