MVP Systems Software  
email us now

Watching for Files on OpenVMS

Expand / Collapse
 

Watching for Files on OpenVMS


Watching for files with JAMS for OpenVMS is a little different than watching for files with JAMS for Windows.  The Windows NTFS file system has hooks that will send us events when a file is created or deleted and we don't have those hooks in the OpenVMS ODS2 file system.

There are two basic scenarios where we need to watch for a file:
  • When we know the aproximate time that a file will arrive and we have a job scheduled to process the file.
  • When we don't know when a file will arrive and we want to submit a job whenever the file does arrive.

The first scenario is easily handled with a precheck job.  You can create a generic "file" precheck which 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, you simply set it as the precheck job in the primary job definition (the job that needs to wait for the file). You also have 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 seens the file it completes succesfully which is the signal to JAMS that the primary job can be released.

The second scenario is accomplished using JAMS Triggers and Variable events. First, you need a job that will watch for the file. You can tell JAMS to resubmit the job every few minutes or you could put a loop in 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 just sets a JAMS Variable named FILES_ARE_READY to true. Now, you can 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

One detail of note, 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.



Rate this Article:

Add Your Comments


Name: *
Email Address:
Web Address:
   
  
 
 
   
Verification Code:
*
 

Details
Last Modified:Thursday, August 19, 2010

Last Modified By: JohnV

Type: HOWTO

Article not rated yet.

Article has been viewed 335 times.

Options