Watching for files with JAMS for OpenVMS is different than watching for files with JAMS for Windows. The Windows NTFS file system has hooks that will send events when a file is created or deleted. These hooks do not exist in the OpenVMS ODS2 file system.
There are two basic scenarios where is it necessary to monitor for a file:
- When the aproximate time that a file will arrive is known and we have a job scheduled to process the file.
- When it is unknown when a file will arrive and a job needs to be submitted whenever the file does arrive.
The first scenario is easily handled with a precheck job. Create a generic "file" precheck job which obtains the file specification from the job that it is checking for. Here is the DCL source:
$! $! FILE_PRECHECK - This is a generic job which is used as a precheck $! to look for a file. $! $! We get the filename that we're looking for from $! the job that we're checking for. We look at the P1 $! parameter from that job which should be a filename. $! $! Get the filename from P1 of the job we're checking for $! $ fileName = f$getqui("DISPLAY_ENTRY", "PARAMETER_1", <<JAMS_PRECHECK_ENTRY>>) $! $Check_Loop: $ if (f$search(fileName) .nes. "") $ then $ exit 1 $ endif $ wait 00:00:30 $ goto Check_Loop $!
To use this, set it as the precheck job in the primary job definition (the job that needs to wait for the file). Also be sure to add a P1 parameter to that job and set the value of the parameter to the file specification to look for. After that, when the primary job is scheduled to start, JAMS will submit the precheck job which looks for the file. When it sees the file, it completes succesfully. This is the signal to JAMS that the primary job can be released.
The second scenario is accomplished using JAMS Triggers and Variable events. First, create a job that will watch for the file. This job can be scheduled in JAMS to resubmit every few minutes or can be placed in a loop within the job. Here is an example that would be resubmitted every few minutes:
$! $! FILE_WATCHER - A job that watches for a file and sets a JAMS $! Variable when the file arrives $! $ JAMS :== $MCR JAMS_EXE:JAMS_MASTER.EXE $! $ if (f$search("DISK:[INCOMING]*.DAT") .nes. "") $ then $ JAMS SET VARIABLE FILES_ARE_READY TRUE $ endif
When this job sees a matching file, it sets a JAMS Variable named FILES_ARE_READY to true. Now, create Trigger Events or dependencies that are based on that variable. Here is a JAMS Trigger definition:
DEFINE TRIGGER PROCESS_FILES DESCRIPTION "Process the files that FILE_WATCHER detects" EVENT VARIABLE FILES_ARE_READY TRUE END_EVENT ACTION SUBMIT JOB PROCESS_FILE END_ACTION END_TRIGGER
Note that the trigger definition is not auto reset to prevent the PROCESS_FILE job from being submitted multiple times. After the PROCESS_FILE job has processed the files, it should do a JAMS RESET TRIGGER PROCESS_FILES to reset the trigger for the next file arrival.
Comments