"Job must not be running" condition

Andrew (22 posts)
February 11, 2016 08:02 AM
Accepted Answer

Hello,

I'm trying to set up a race condition between two jobs that cannot run simultaneously. They'll be triggered to run at the same time with a condition that waits for a file to arrive from a vendor. I added a condition on each job that the other job must not be running. Unfortunately, adTempus seems to translate "Waiting for Condition" status as "running" for the purposes of evaluating the condition.

Is there a way for the two jobs to check that the other one is not in "Running" status? I'd like the jobs to be able to execute while the other is in Waiting for Condition status.

adTempus 3.0.8

 

Thanks,
Andy

Bill Staff (599 posts)
February 11, 2016 09:52 AM
Accepted Answer

You're right--"Waiting for Condition" is considered "Running" for purposes of the condition.

One approach would be to use a File Trigger instead of a File Condition, so they're not waiting around for the file. You could then use the Job Condition to keep them from running at the same time, or put them both in a Queue that has a limit of 1 concurrent job.

If you need to use the File Condition for some reason instead of a File Trigger, you could use a semaphore file instead of the job condition: have each job run a script to create a file as the first step and delete it as the last step. The other job would use a File Condition to not run if the file exists (indicating that the job is active).

You can't use the queue limit instead of the job condition in your current setup (with a file condition) because the queue will also count "Waiting for Condition" as active and prevent the second job from starting.

Starting with version 4, jobs that are waiting for condition don't count against the job limit for a queue, but they're still be considered "running" for purpose of job conditions.

Andrew (22 posts)
February 11, 2016 01:53 PM
Accepted Answer

The files are located on secure FTPs so we use custom C# scripts that check for the files instead of using the native File Trigger. I really like the idea of using a separate queue with the concurrency rule. That's pretty neat.

I think your file suggestion is a great workaround. I implemented it a bit differently to keep everything within the adTempus console and not use an external file.

I created "Running" versions of my jobs (so "Job A Running" and "Job B Running") that have conditions on their related jobs ("Job A" and "Job B"). This jobs are triggered by responses of their related jobs ("Job A" and "Job B").

So when Job A starts running, a response triggers Job A Running. When Job A completes,  the conditions on the Running job resolves and it completes. So now I have these Running jobs that are only in "Running" status when the jobs are actually executing. This means that I can have a condition on Job A that makes sure Job B Running is not running. And Job B has a condition to make sure Job A Running is not running.

Thanks for the suggestion. Hope you're not cringing at my implementation.

Bill Staff (599 posts)
February 11, 2016 03:09 PM
Accepted Answer

Hey, as long as it does what you need.

FYI beginning with adTempus 4 the File Trigger supports FTP/FTPS and SFTP.

Andrew (22 posts)
February 12, 2016 11:10 AM
Accepted Answer

One last update:

I should urge caution here because I accidentally set the response on Job A to start Job A, which created an infinite loop, starting 12k instances over 7 hours and bringing down the master.

Aside from that, works like a charm.

Replies are disabled for this topic.