Question

What I would like is an example job that does the following:

1) File comes in, is fully downloaded and then kicks off a FolderWatcher Job

2) Based on the criteria the file name matches, it will kick off another task

3) Task 3: Job execution task

I have items 1 and 3, but need an example for item 2 (a task that has some logic to specify which task to call next). Ideally, it would be something akin to:

 ...
 if (FileName.FilterMatch1 = true)
 {
            Call Task FilterMatch1Execute();
 }
 elseif (FileName.FilterMatch2 = true)
 {
            Call Task FilterMatch2Execute();
 }
 ...

Answer

You set up a job chain, using file_order_source objects. These objects poll (Unix systems) or use the host computer's operating system (Windows) to monitor a specified directory. When a file is added to this directory a regular expression specified for the file_order_source object is used to test for a specific pattern in the file's name. A pattern match in the file name causes JobScheduler to generate an order for the job chain. This order will start at the node in the job chain, whose name has specified in JOE as the "start node" and that is also specified for the file_order_source configuration using the next_state attribute.

Note that JobScheduler uses regular expressions to carry out these tests, which allows more sophisticated search patterns than so called "wildcards".

Configuration in JOE

The logic behind the job chain is shown in the following screen shot of the JOE "Diagram" tab:

One of the two "checkSteadyState" jobs will be started when a file whose name matches a particular pattern is added to a particular directory as described above.
Once either of these "checkSteadyState" jobs has been completed, the corresponding "setParams" job will be executed before the order proceeds to "step1" in the job chain and then completion (the "success" node).

The job chain is shown in more detail in JOE's "Node" tab as shown in the next screen shot:

The directories that are monitored by the two jobs "checkSteadyState" jobs are set in JOE's "File event" tab as are the regular expressions used to match the pattern in the names of files added to the directories in question. This can be seen in the screen shot below:

In this example, both file_order_sources monitor the same deirectory but use different regular expressions to filter the files arriving:

  • The "NoNZ_checkSteadyState" source checks whether a file of type "zip" whose name starts with "08" or whether a file of type "pgp" whose name starts with "13" has been added to the directory;
  • The "NZ_checkSteadyState" source checks whether a file of type "pgp" whose name starts with a number between "01" and "18" (but not "08" or "13") has been added to the directory.

Configuration in XML

The two "checkSteadyState" jobs described above are started by file_order_source objects. Although notdirectly visible in JOE these are generated by JOE in the background and can be seen in lines 2 and 3 of the XML listing of the job chain (see below). The file_order_source object parameters have the following purpose:

  • "directory" is the directory being monitored,
  • "regex" is the regularexpression used to match the file name and
  • "next_state" is the name of the job to be started when the file_order_source is triggered.
<?xml version="1.0" encoding="iso-8859-1"?>
 <job_chain  orders_recoverable="yes">
    <file_order_source  directory="\\asc-stg1p\hshare\ftptest\1420\Inbound\" regex="^08.*\.zip$|^13.*\.pgp$"      next_state="NoNZ_checkSteadyState"/>
    <file_order_source  directory="\\asc-stg1p\hshare\ftptest\1420\Inbound\" regex="(^01.*|^02.*|^03.*|^04.*|^05.*|^06.*|^07.*|^09.*|^10.*|^11.*|^12.*|^14.*|^15.*|^16.*|^17.*|^18.*)\.pgp$" next_state="NZ_checkSteadyState"/>
 
    <job_chain_node  state="NoNZ_checkSteadyState" job="../checkSteadyState" next_state="NoNZ_setParams" error_state="!checkSteadyState" on_error="suspend"/>
    <job_chain_node  state="NoNZ_setParams" job="setParams-asc-stg1p-hshare-ftptest-1420-Inbound-NoNZ.pgp" next_state="step1" error_state="!NoNZ_setParams" on_error="suspend"/>
 
    <job_chain_node  state="NZ_checkSteadyState" job="../checkSteadyState" next_state="NZ_setParams" error_state="!checkSteadyState" on_error="suspend"/>
    <job_chain_node  state="NZ_setParams" job="setParams-asc-stg1p-hshare-ftptest-1420-Inbound-NZ.pgp" next_state="step1" error_state="!NZ_setParams" on_error="suspend"/>
 
    <job_chain_node  state="step1" job="../startJob" next_state="success" error_state="!step1" on_error="suspend"/>
 
    <job_chain_node.end  state="!checkSteadyState"/>
    <job_chain_node.end  state="!NoNZ_setParams"/>
    <job_chain_node.end  state="!NZ_setParams"/>
    <job_chain_node.end  state="!step1"/>
    <job_chain_node.end  state="success"/>
 </job_chain>

A job chain can have more than one file_order_source and its associated regular expression and next_state. Here, the next_state is the state where the job chain has to start processing.

See also: