Creating a fenceline job

Paul Watson (101 posts)
March 10, 2015 09:30 AM
Accepted Answer

We have a several jobs that run as a group to process a single application request. We are running on adTempus 3.0.8.1.

START request
Request step 1
Request step 2
Request step n
END request

While a request is being processed, we must prevent another request from being started. I know there is an option to not start a job instance if one is already running, but in our case, the "START request" job will have started the next job and ended. We need to stop another "START request" job from running if -any- of the jobs are running.

I thought that I might start a "Fenceline" job in "START request" that would continue to run until "END request" terminated it. How can I keep "Fenceline" running (using as few system resources as possible) until "END request" terminates it?

Is there a better way? Please advise. Thanks.

Bill Staff (599 posts)
March 10, 2015 10:29 AM
Accepted Answer

I think the easiest approach would be to use a semaphore file, rather than trying to set up a job as you described.

For your "START Request" job, put a script as the first step to create a file with some arbitrary data in whatever location makes sense, e.g., "c:\jobs\process_x_running.txt". Also add a File Condition to the job so it doesn't run if that file already exists (skipping or waiting, as appropriate for your scenario).

Add a step to the "END Request" job to delete the file when everything else is finished.

Is there a functional need to have the pieces running as separate jobs instead of steps in a single job? If they can be combined into a single job, then you could just use the multiple instance rules.

Paul Watson (101 posts)
March 10, 2015 10:35 AM
Accepted Answer

Thanks for your quick reply, Bill.

I will try the semaphore file approach.

Attached is an export of three (3) jobs that -almost- do what I described earlier. The only thing I see not working is when "RUNNING STOP" tells "RUNNING STDEXT" to terminate, but it doesn't. Any ideas?

Paul Watson (101 posts)
March 10, 2015 11:51 AM
Accepted Answer

As a side note, when I opened the RunningFenceline.adtexport file in Microsoft XMLNotepad 2007, what appears to be an error message appeared at the bottom status line. Is this important?

Error loading "http://www.arcanadev.com/schemas/adtempus/301/persistentobject.xsd"

 

Bill Staff (599 posts)
March 10, 2015 01:29 PM
Accepted Answer

Your file wasn't attached--the forum only allows image files. You will need to post screen captures of the relevant parts of the jobs or describe what you're doing.

That error message is not important.

Paul Watson (101 posts)
March 10, 2015 01:47 PM
Accepted Answer

I do see the upper case letters specifying that only JPG, GIF, and PNG formats are uploadable. If I had time, I might wonder why a product file such as an .adtexport file could not be uploaded

There are three (3) jobs.

RUNNING START
RUNNING STDEXT
RUNNING STOP

RUNNING START has a Condition that RUNNING STDEXT is not running. Otherwise, it skips the job and does not report a failure. The only Step is to send a notification message. If the job fails, a notification is sent. If it succeeds, a notification is sent and RUNNING STDEXT is started.

RUNNING STDEXT is the job that should be running whenever any of the application jobs are running. If RUNNING STDEXT is running, another use of the application must not be started. The Step is a VBScript with an infinite loop; while 1<>0.

When RUNNING STOP is called, it has a Condition that RUNNING STDEXT must be running. The only Step is a NOOP; return 0, which does nothing. The Response is at the Beginning of the job to Terminate job "RUNNING STDEXT."

All seems to be working except the termination of RUNNING STDEXT. Any suggestions?

 

 

Bill Staff (599 posts)
March 11, 2015 10:13 AM
Accepted Answer

It may be that the script engine isn't able to kill your script while it's in the loop. Are you doing something in the loop, like sleeping, or just looping?

I tried a VB.NET script with this code and it worked fine:

While True
    System.Threading.Thread.Sleep(1000)
End While

Paul Watson (101 posts)
March 11, 2015 10:41 AM
Accepted Answer

I added a call to Sleep() as you described, but have the same result; the job is not terminated.

In the mean time, I implemented the file presence lock as you described. It is working, but I would like to know why this does not work.

Replies are disabled for this topic.