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

Tags