Skip to end of metadata
Go to start of metadata

Solution

Download

  • Download the attached archive: 
  • Unzip the archive to the live folder of your JobScheduler installation
  • Create inbound, success and error directories
  • Adjust the configuration to your environment

Components

  • A job chain that monitors the directory for incoming files
  • A job that prints the name of the incoming file to stdout

Introduction  

This feature can be useful to dynamically process large number of incoming files, e.g. upload transactions into a database, convert meta files to PDF files, convert image file formats etc.. JobScheduler's File Order Source feature simplifies business processes that should be triggered on arrival of a file.

A job chain can be triggered by two types of orders:

  • Time based orders
  • File based orders. By use of a File Order Source a job chain can be configured to start immediately on arrival of a file in a directory.

A File Order Source requires two parameters

  • Directory that specifies the file system location where JobScheduler should watch for incoming files
  • Regex that is the Regular Expression that names of incoming files have to match to trigger the job chain. A most simple example of File Order Source is 
    <file_order_source directory="c:\sandbox\outgoing" regex="^test.txt$"/>.

How to configure a job chain for a File Order Source

To learn how to create a job chain, refer following the article JobScheduler - Tutorial 2 - Editing a Simple Job with JOE

 

  1. Open your job chain in JOE (JobScheduler Object Editor), expand job chain configuration by clicking on Job Chains --> FileWatching and click on Steps/Nodes.
  2. From right window pan select File Order Source tab.
  3. Click on New File Order Source, this will open a dialog to create a new File Order Source configuration.
  4. Click in the text filed in front of Directory parameter, configure directory which should  be watched for arrival of file e.g. c:\sandbox\outgoing.
  5. Click in the text field in-front of Regex parameter, configure file name or Regular Expression e.g. ^test.txt$.
  6. Click Apply File Order Source button to apply your  configuration.
  7. Click Save to save job chain.

Example: job chain - FileWatching 

FileWatchinng.job_chain.xml

Explanation

Following example is a Windows operation system FileWatching job chain example. Job chain FileWatching is configured to start as soon as the file test.txt arrives in the directory c:\sandbox\outgoing. The File Order will processed as a normal JobScheduler Order through job chain, one step to the next, until the Order reaches end node of job chain. In this example there are two distinct job chain end nodes, each one for success and error state of File Order processing. 

Example: job - show_file_name

show_file_name.job.xml

Explanation

By default JobScheduler creates few internal environment variables during the Order processing. All the JobScheduler environment variables are prefixed by SCHEDULER_PARAMS_ prefix. JobScheduler store the trigger file's path in the environment variable SCHEDULER_PARAM_SCHEDULER_FILE_PATH. In the following job example JobScheduler's inbuilt environment variable SCHEDULER_PARAM_SCHEDULER_FILE_PATH will be used to output trigger file name on the console (stdout). 

How to configure File Order Sink - job chain

Every File Order is associated with a file on file system. JobScheduler offers two options to handle files associated with a File Order, Once a File Order reaches to the end success/error node of job chain. File associated with File Order Source either can be remove or move to a different directory on file system. 

Remove File

A file_order_sink node can be configured to remove file after processing e.g.( <file_order_sink state="success" remove="yes"/> ). If File Order Source's parameter remove=yes is set, file associated with the File Order will be deleted from file system location configured in the directory parameter.


  1. Open your job chain in JOE (JobScheduler Object Editor), expand job chain configuration by clicking on Job Chains --> FileWatching and click on Steps/Nodes.
  2. From the right window panel select the Nodes tab.
  3. Click on state success, this will enable the dialog to configure the FIle Sink for success state.
  4. Select radio option File Sink.
  5. Select the check box Remove File to delete incoming files after successful processing. 
  6. Click the Apply Chain Node button to apply your configuration.
  7. Click Save to save the job chain.
  8. Repeat steps 3 to 7 for the error state too.

Move File

file_order_sink node can be configured to move incoming files after processing to a different directory e.g.
<file_order_sink  state="success" remove="no" move_to="c:\sandbox\success"/>). 

 

 

  1. Open your job chain in JOE (JobScheduler Object Editor), expand job chain configuration by clicking on Job Chains --> FileWatching and click on Steps/Nodes.
  2. From the right window panel select the Nodes tab.
  3. Click on state success, this will enable the dialog to configure File Order Sink for success state.
  4. Select the radio option File Sink.
  5. Click in the text field in-front of Move to parameter, configure directory location where file should be move after successful processing  e.g. c:\sandbox\success.
  6. Click Apply Chain Node button to apply your configuration.
  7. Click Save to save job chain.
  8. Repeat steps 3 to 7 for the error state too.

Operation

To trigger the FileWatching job chain, create a file test.txt in the directory c:\sandbox\success. As soon as the file is created, JobScheduler will start the FileWatching job chain. You can check the job chain log with the Order History tab in the JobScheduler Operation Center (JOC).

See also