Page 1 of 1

Design a job with infinite loop

Posted: Fri Jan 18, 2013 1:41 pm
by prasson_ibm
Hi,

I have a requirement where i have to design a sequence job which will keep on running and it will look for trigger file.

Trigger file will be created by another master job,which has source as MQ. This job will also keep on running and as soon as message land up to the MQ it will create trigger file.Design will be look like this:-

Code: Select all

Master Seq  (infinte loop)---> SubSeq1                         ------> seq
                             (infinte loop wait for trigger)
                        ----> SubSeq2                         --------> seq
                        ----> SubSeq3.......100             ---------> seq 


It will have more then 100 distinct sequences which will be always running and waiting for trigger file.Once trigger file created that particular sub sequence should start.My worry is may these infinite running jobs will eat more CPU resources and phantom process.Is it a good approach to design a flow like this.Need experts advice.

Posted: Fri Jan 18, 2013 11:37 pm
by chetan.c
Not an expert , but this is how we had done it.
Since the OS is mentioned as UNIX.
A while loop with a condition for controlling the start and stop of the loop.

In the while loop , check for the existence of the trigger file ,if present run the job using the dsjob command else some wait time to recheck for existence of the trigger file.
Once the job is completed , the while loop will continue to check the existence of the file.

Thanks,
Chetan.C

Posted: Sat Jan 19, 2013 12:01 am
by prasson_ibm
Hi Chetan,
Thanks for your input,but we cant use unix script here to create a loop,this we are doing in job sequence.

Posted: Sat Jan 19, 2013 3:39 am
by ray.wurlod
You need a clean mechaism for shutting down the sequence. Therefore you should set a timeout on the WaitForFile activity. If this triggers (Failure trigger = timeout) take a branch to check for the existence of another file that indicates that the sequence should shut down and, if found, invoke a Terminator activity.

The other problem is how to set up an infinite loop in a sequence. A counted loop that has a very large limit should be close enough for your needs.

Posted: Sat Jan 19, 2013 8:36 am
by chulett
There is no such thing as an "infinite loop" in a Sequence job, nor is it a good idea to run one 24x7. At the very least have it stop once a day and then schedule it to restart shortly thereafter.

Posted: Sat Jan 19, 2013 9:36 am
by ArndW
I implemented such a job sequence a while back and seem to recall having had problems at either 32K or 64K iterations. Best to let it stop and restart before it reaches that number of iterations.

Posted: Mon Jan 21, 2013 1:45 am
by prasson_ibm
Hi Everyone,

Thanks for your input.My client is very rigid and they dont want to change their flow so we cant directly schedule our jobs in appworks.
We have only this option to look for trigger file which is given to DS as MQ message and then need to trigger out sub sequence.For loop we have given from 1 to 99999. I hope it will cover many iteration.

Thanks
Prasoon

Posted: Mon Jan 21, 2013 8:13 am
by chulett
Ok... 1 to 99999, then what happens? :?

Posted: Mon Jan 21, 2013 9:27 am
by ArndW
If you need more, put in another 999999 outer loop, giving you a total of 9999800001 iterations.

Posted: Mon Jan 21, 2013 11:44 am
by chulett
That's crazy talk, as noted I would never design anything of the sort. However... maybe that's just me. :P

Posted: Mon Jan 21, 2013 11:56 am
by ArndW
If he'd written that the platform was Windows I wouldn't have worried about reaching either number as a system reboot would almost certainly occur before that was reached. UNIX has a better chance, but might run out of memory before doing so :)