user3332279
user3332279

Reputation: 59

SFTP download from dynamic directories using Apache Camel

On a same SFTP location, there are day wise structure as bellow.

Folowing route is working fine and each 30S the consumer checks the SFTP location and downloads .txt files.

from("sftp://user@host?antInclude=*/*/*/*.txt"
                + "&password=xxx" + "&recursive=true" + "&idempotent=true"
                + "&scheduler=spring&scheduler.cron=0/30+*+*+*+*+?")
            .to("file:/home/user/data");

But above route will scan ALL the directories in the SFTP location and it MAY be a performance issue. So I need to scan only for today and previous day like bellow.

from("sftp://user@host?antInclude=2014/07/03/*.txt,2014/07/02/*.txt"
                + "&password=xxx" + "&recursive=true" + "&idempotent=true"
                + "&scheduler=spring&scheduler.cron=0/30+*+*+*+*+?")
            .to("file:/home/user/data");

But, I need to use dynamic directory pattern for antInclude= option. I am trying with several approaches but it was not success. Can you please give me an idea with your experience.

Upvotes: 1

Views: 1067

Answers (1)

Peter Keller
Peter Keller

Reputation: 7636

The source endpoint is not dynamic. If you need to change it, process as described here. So, one possible solution could be to use a scheduler to update the route every day. Not very elegant, I know.

Upvotes: 0

Related Questions