Monday, March 26, 2012

Making FTP Task retry until file shows up

If I want to download a file, but I don't know if it's available yet (actually positive it won't be available for some time), how do I make FTP Task retry/wait until file shows up in the ftp folder?You can have a loop that continues until you set a variable to a certain value to indicate success, In addition add a script task that has a line Thread.sleep(1000). That will sleep the package for 1second, you will need to add imports System.Threading to the Script task at the top. The other option is to schedule your package to run every minute or 5 minutes. This has the benefit in that you don't have a long running package which can be prone to issues or failures. In this case if the package fails thats fine because the package will just be run the next scheduled time. You do have to consider overlapping of the schedule here. You don't want two instances of the package running.

No comments:

Post a Comment