I'm trying to use Apache Camel to download and route files from an FTP server. However, files are only added to the FTP server once in a long while so having the program running continuously seems a bit overzealous. Instead, I would rather have a cronjob that runs weekly and processes any new files that have been added to the server.
Is there any way to get Camel to automatically shutdown once it no longer has any new files to process?
My current main
function looks like this:
public static void main (String[] args) throws Exception {
org.apache.camel.spring.Main main = new org.apache.camel.spring.Main ();
main.setApplicationContextUri ("applicationContext.xml");
main.enableHangupSupport ();
main.run (args);
}
And the interesting part of the applicationContext.xml
is:
<camelContext>
<route>
<from uri="ftp://ftp.example.com/remoteDir?username=user&password=pass"/>
<to uri="file:../ftp_data?tempPrefix=."/>
</route>
</camelContext>