I am new to Camel FTP and need little help rather desperately to accomplish a task.
I am working on a requirement to download couple of reports via FTP twice a month and upload them to SharePoint.
I have configured an FTP Route with a filter to pickup required files and a route policy using CronScheduledRoutePolicy to run this route twice every month. Please see below configurations.
<!-- FileName filter for ACE Report download from CSREPORT folder -->
<bean id="aceReportFileNameFilter" class="com.xyz.ACEReportFileNameFilter" />
<bean id="aceReportDownloadStartPolicy"
class="org.apache.camel.routepolicy.quartz2.CronScheduledRoutePolicy">
<!-- start every 2min from monday to saturday - TESTING -->
<property name="routeStartTime" value="0 0/2 * ? * 1-6 *" />
<!-- Run every 2nd and 23rd of the month at 1AM - PRODUCTION -->
<!-- <property name="routeStartTime" value="0 0 1 2,23 * ? *" /> -->
</bean>
<routeContext id="aceReportDownload" xmlns="http://camel.apache.org/schema/spring">
<route autoStartup="false" id="CSReportFtp" routePolicyRef="aceReportDownloadStartPolicy">
<from id="_from1"
uri="ftp://user:pwd@host:port/reportFolder?filter=#aceReportFileNameFilter" />
<log message="Testing ACE report FTP download" />
<to id="_to1" uri="file://{{downloadFolderPath}}/temp" />
</route>
</routeContext>
Route is downloading the files as per used filter however, its is polling for the files continuously rather than stopping having downloaded the files. Here are the logs from my machine.
12:12:00.049 [DefaultQuartzScheduler-LISA_Worker-1] INFO o.a.camel.spring.SpringCamelContext - Route: CSReportFtp started and consuming from: Endpoint[ftp://PCP03D:xxxxxx@localhost:53556/CSREPORT?disconnect=true&filter=%23aceReportFileNameFilter] 12:12:01.235 [Camel (LISA) thread #0 - ftp://PCP03D:xxxxxx@localhost:53556/CSREPORT] INFO CSReportFtp - Testing ACE report FTP download 12:12:01.283 [Camel (LISA) thread #0 - ftp://PCP03D:xxxxxx@localhost:53556/CSREPORT] INFO CSReportFtp - Testing ACE report FTP download 12:12:01.815 [Camel (LISA) thread #0 - ftp://PCP03D:xxxxxx@localhost:53556/CSREPORT] INFO CSReportFtp - Testing ACE report FTP download 12:12:01.846 [Camel (LISA) thread #0 - ftp://PCP03D:xxxxxx@localhost:53556/CSREPORT] INFO CSReportFtp - Testing ACE report FTP download 12:12:02.407 [Camel (LISA) thread #0 - ftp://PCP03D:xxxxxx@localhost:53556/CSREPORT] INFO CSReportFtp - Testing ACE report FTP download ........ ........
I want files to be downloaded only once as per CronScheduledRoutePolicy so that I can then upload reports to SharePoint.
I have searched for possible solutions and tried couple of things like passing disconnect parameter to close FTP connection and trying to close Route using < onCompletion> DSL etc. However, that has not worked.
I have come across what looks like a workaround (I haven't tried it yet) like this one How to get Camel FTP to fetch only once on demand
This is not the exact scenario for me.
Can someone please advise on an intuitive solution for my requirement. Any help would be greatly appreciated. Thanks