You can add a File Watch Task step to a taskflow to listen to files in a defined location and monitor file events.
In the File Watch Task step, you can select an existing file listener with the connector source type. You can use file events to orchestrate taskflow execution. For example, you can wait for a file to arrive at a particular location and then consume the file in a subsequent step.
When you run a taskflow that contains a File Watch Task step, the associated file listener starts. When a file event occurs, the file watch task runs and sends the file event details such as a list of arrived, updated, and deleted files along with the file details. The taskflow then proceeds to the subsequent steps.
If a file event does not occur, by default, the taskflow waits for 5 minutes or for the overridden value defined in the
Time Out
field. After that, the File Watch Task step completes and the taskflow proceeds to the subsequent steps.
The maximum value that you can define in the
Time Out
field is 7 days. After 7 days, the taskflow status changes to suspended.
The following sections describe the File Watch Task step properties:
General properties
In the general properties, you can specify a descriptive name for the File Watch Task step.
The name can contain only alphanumeric characters, underscores (_), spaces, and Unicode characters. The name can't contain curly brackets {}.
File Watch Task step properties
In the File Watch Task step properties, you can select an existing file listener with the connector source type that you want to add to the taskflow. When you select a file listener, you see a description and output fields for the file listener.
The
Output Fields
section shows the
fileEvents
field. The
fileEvents
field is a list of objects that return the file event details such as a list of arrived, updated, and deleted files along with the file details. The
fileEvents
field displays a maximum of 1,500 records even if the total number of processed files exceeds 1,500.
Input fields
You can add input fields to override the following file listener properties:
Notify if files exist on first run
Runtime Environment
Source Connection
Time Out
File Pattern
Folder Path
Events
Configure the
Events
properties to add timers to a file watch task.
Use a Timer event to perform an action based on a schedule. The action could be either at a specific time or after an interval.
When you add a timer to a File Watch Task step, a new branch appears. Add an event to this branch and specify whether you want the event to run
At
a specific time or
After
an interval.
In the following image, the event on the timer branch is a Decision step (Decision 1) that occurs five minutes after the main file watch task (File Watch Task 1) starts:
Main branch
Timer branch
In the example, the timer branch runs five minutes after File Watch Task 1 starts. If File Watch Task 1 finishes before Decision 1, the timer branch is not executed.
You can select the
Interrupting
option if you want the timer to interrupt the main file watch task.
The following image shows an interrupting timer set to occur five minutes after the main file watch task starts:
Main branch
Timer branch
In the example, File Watch Task 2 executes after five minutes and interrupts File Watch Task 1. The taskflow executes only File Watch Task 2 and then ends. File Watch Task 1 has no output in this taskflow instance. You see no output fields for File Watch Task 1 in the job details for the taskflow.
If File Watch Task 1 completes before the timer, the taskflow executes only File Watch Task 1 and ends.
If you delete the End step on the timer branch of an interrupting timer, the timer branch rejoins the main branch.
The following image shows an interrupting timer branch with the End step deleted:
Main branch
Timer branch
In the example, File Watch Task 2 executes after five minutes and interrupts File Watch Task 1. The timer branch rejoins the main branch. The taskflow executes File Watch Task 2, a Decision step, a Parallel Paths step, and then ends.
If File Watch Task 1 completes before the timer, the taskflow executes File Watch Task 1, a Decision step, a Parallel Paths step, and then ends.
Error handling properties
Use the
Error Handling
tab to indicate how you want the taskflow to behave when a File Watch Task step encounters an error. After you select a file listener, you can configure the
On Error
property.
The
On Error
property defines the path that a taskflow takes when it encounters an error in a File Watch Task step. An error occurs when a File Watch Task step fails. You can choose from the following options:
Select
Ignore
to ignore the error and move to the next step.
Select
Suspend Taskflow
to move the taskflow to the suspended state when it encounters an error. You can resume the taskflow instance from the
All Jobs
,
Running Jobs
, or
My Jobs
page. The taskflow resumes from the step at which it was suspended. If you know the reason for the error, correct the issue and then resume the taskflow.
Select
Custom error handling
to handle the error in a manner you choose. If you select
Custom error handling
, two branches appear. The first branch is the path that the taskflow follows if no error occurs. The second branch is the custom path that the taskflow follows if an error occurs.
The following image shows a custom error handling path with a File Watch Task step: