Using Premium File Watcher Task to Monitor File Changes in an ETL Process

30 March 2023
KingswaySoft Team

In general integration scenarios, it is a very common use case to monitor a folder path, and as soon as a file with certain criteria lands in it or gets modified, a process or recipient should be notified. With the new Premium File Watcher Task added to our SSIS Productivity Pack in our most recent v23.1 release, this can be easily automated. The utility of such a feature ranges from a simple email notification to triggering other tasks based on a precedence. And the ease of design for such a file monitoring system makes it extremely useful.

In this blog post, we will be demonstrating the design and configurations required to watch a file path on a continuous basis and send an email notifications when a specific change happens in it. The components shown below would be used in this example:

As mentioned, you will need to have SSIS Productivity Pack v23.1 or above installed in order to be able to access the Premium File Watcher Task. 

Design

The first step would be to configure the Premium File Watcher Task, which needs a folder path to get started. And then, it requires filter criteria through which the files would be filtered upon. This would be an optional field, and if you just wish to detect if there are any files that land in the folder, then you could leave the filter field empty. In our example, we would be looking for Excel files, so we have set the Filter to be *.xlsx. The Properties to Watch has been set as "Item Created" which would mean that the file watcher component only looks out for newly created files. Multiple options can be chosen from the list to have more actions monitored as per your requirement. Watch mode is set to "Until Service Is Stopped" which allows the component to exit the watch mode till a file is found.

Premium File Watcher Task.png

The Output property that we are looking for is "Name" which is the name of the newly created file, and this will be stored in a string variable "Output". 

In the control flow, you could use a For Loop Container in the SSIS package, to have the file watcher wait for the files. And so the package design would look like something below:

Inside the loop, the Premium File Watcher task is connected in series to an SMTP Task, which is used to send out an email notification once the files are detected. For this, configure the SMTP task as shown below.

SMTP Task.png

In the "Content" page, use the "Output" variable that has the filename in the email body.

SMTP Task Advanced editor.png

Now, we create two datetime type variables in SSIS:

  • User::CurrentDateTime: GETDATE()
  • User::EndTime: (DT_DBTIMESTAMP) ((DT_WSTR,20)(DT_DBDATE)GETDATE()+ " 11:59:59 PM")

Variable expressions.png

These two variables would be used in For Loop EvalExpression to specify when the loop stops.

  • @[User::CurrentDateTime]<@[User::EndTime]

In our SSIS agent job, we could set the For Loop to stop and start daily accordingly at 12:00 am.

For Loop expression.png

Closing Notes

The Premium File Watcher task opens up possibilities to expand your integration scenarios in which a folder (same level and recursively) should be watched for file changes in order to trigger further ETL processes in your SSIS packages. The scenario above is a relatively simple example that shows how it works, which can be used as a starting reference solution. You could be even more creative with the availability of the solution.

We hope this has helped!

Archive

December 2024 1 November 2024 3 October 2024 1 September 2024 1 August 2024 2 July 2024 1 June 2024 1 May 2024 1 April 2024 2 March 2024 2 February 2024 2 January 2024 2 December 2023 1 November 2023 1 October 2023 2 August 2023 1 July 2023 2 June 2023 1 May 2023 2 April 2023 1 March 2023 1 February 2023 1 January 2023 2 December 2022 1 November 2022 2 October 2022 2 September 2022 2 August 2022 2 July 2022 3 June 2022 2 May 2022 2 April 2022 3 March 2022 2 February 2022 1 January 2022 2 December 2021 1 October 2021 1 September 2021 2 August 2021 2 July 2021 2 June 2021 1 May 2021 1 April 2021 2 March 2021 2 February 2021 2 January 2021 2 December 2020 2 November 2020 4 October 2020 1 September 2020 3 August 2020 2 July 2020 1 June 2020 2 May 2020 1 April 2020 1 March 2020 1 February 2020 1 January 2020 1 December 2019 1 November 2019 1 October 2019 1 May 2019 1 February 2019 1 December 2018 2 November 2018 1 October 2018 4 September 2018 1 August 2018 1 July 2018 1 June 2018 3 April 2018 3 March 2018 3 February 2018 3 January 2018 2 December 2017 1 April 2017 1 March 2017 7 December 2016 1 November 2016 2 October 2016 1 September 2016 4 August 2016 1 June 2016 1 May 2016 3 April 2016 1 August 2015 1 April 2015 10 August 2014 1 July 2014 1 June 2014 2 May 2014 2 February 2014 1 January 2014 2 October 2013 1 September 2013 2 August 2013 2 June 2013 5 May 2013 2 March 2013 1 February 2013 1 January 2013 1 December 2012 2 November 2012 2 September 2012 2 July 2012 1 May 2012 3 April 2012 2 March 2012 2 January 2012 1

Tags