synchronize jobs

20 pts.
Tags:
CLP
RPG ILE
RPGLE
Hi! How can I synchronize two or more RPGLE/CL programs that are executed via SBMJOB command, in order to avoid conflicts in using files and dataareas? If you could send me an example, it'll be greatly appreciated. Thanx in advance, Meli :)

Answer Wiki

Thanks. We'll let you know when a new response is added.

Hi Melissa

It all depends on exactly what your requirements are. Do the jobs have to run at the same time or can they be run after each other? Does one job have to finish before the other can start or is just a process in the middle of the job that you are worried about. Are the jobs part of a third party package that you don’t have the source for?

The way I would probably tackle this, assuming you have the source for the programs, would be to either allocate an exclusive lock on an object or use a data area for “locking” the jobs as and when required.

If I used the allocate object method, I would allocate an exclusive lock at the point that I wanted to check for a conflict and if I failed to lock the object then I would delay the job for a short period of time – say 30-60 seconds (or longer depending on the process) before trying again and repeat this process until the object is free.

Immediately after the process completes I would release the lock so the other process could use it. This logic would need to be put in each job that you wanted to synchronise. If locking an object would cause problems in other routines then I would create a 1 character data area or table just for use by the two jobs as a “flag” object and lock that.

Using data areas I would create a data area that I would simply retrieve the contents of at the syncronising point and depeending on the contents would either delay the job or continue. Similarly to the allocate lock method I would write a value to the data area that indicated “lock” and another value that indicated “free” as appropriate.

For the data area method I would probably use something like the qualified job name as the locking value and blanks as the “free” value so that support personnel could see by interrogating the data area which job had the “lock” at the time.

Hope it helps

Jonathan

==================================================

Since you’re running a multi-user, multi-tasking system that can accommodate multiple concurrent locks on data objects, can you describe your problem a little more? Why do you think it’s necessary to “avoid conflicts” in using files and dataareas? What conflicts are trouble for you?

Without a description of the conflicts, there is no way to know good ways to “avoid” them nor if it even should be done.

Tom

Discuss This Question: 4  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Saratusthra
    Not sure exactly what you want to synchronize but to avoid object locks, including DTAARAs and files, the best approach is streaming the jobs into a single-job JOBQ, which is done in the SBMJOB command. After some analysis, the jobs can be arranged sequentially in logical order before being submitted. This way, a job will finish using objects that may be affected by the next on the queue but there will never be a conflict. The other way is calling the jobs in the desired order within a CL. Hope this helps. Good luck!
    0 pointsBadges:
    report
  • RolandT
    If you create a jobq that only allows one job to run at a time, then submit your jobs to that queue. The system will run the jobs in the sequence submitted, but only one at a time.
    0 pointsBadges:
    report
  • Jwebb901
    To break your job into 4 pieces and then submit them individualy, is self defeating.........now you have all the additional overhead of the job process x 4. One job will process faster than 4, unless of course you have a multi-processor box.
    0 pointsBadges:
    report
  • Splat
    Last time I needed to do something similar, I used a combination of the single-threaded job queue method and the data area control flag method. This allowed me to make sure the prior job had completed normally before the next job could run (I had a section at the top of the CL to re-submit the job fifteen minutes later if the data area showed the prior job hadn't completed).
    6,875 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following