public interface JobDependencyRule
This interface can control how jobs are scheduled. Jobs that are associated to a particular dependency rule have their scheduling dates restricted based on that dependency rule. The typical use of this is to only allow a group of jobs to be scheduled if a dependency rule is satisfied. The rule can be satisified by an external trigger or by a another job making calls on the methods in this interface.
Here is a basic example of how to use dependency rules to allow the schedule and execution of one job control if and when another job can run. In this example job B will not run (even if its schedule is reached) until job A has run.
1) Create job A and schedule it to run at 5:00AM 2) Create a new dependency rule called for example "depA" 3) Schedule job B to start at 5:00AM 4) Associate job B with dependency rule "depA" 5) Now when job A runs and completes successfully have it make the following calls in the SOAFaces API like this: JobDependencyRule depRule = jobContext.getDependencyRule("depA"); depRule.setJobSchedulingAllowed(T1, T2);//you can use depRule.setJobSchedulingAllowed() //without T1 or T1 if you want the rule turned //off indefinitely so that there is no //restriction when job B can run When job A completes its work successfully it should make the calls as shown above, job B will now be able to run between times T1 and T2.
Here is an even more advanced example of using dependency rules. You can use Dependency Rules for the situation where you can force only one instance of a job to ever be scheduled. So when Job A runs it will activate the Dependency Rule it is associated with. This way another instance of the job will not be scheduled for running until this instance has completed.
It would work something like this:
1) Create job A and schedule it to run every minute 2) Create a new dependency rule called for example "JobA One at a Time" 3) Associate job A with dependency rule "JobA One at a Time" 4) Now when job A runs have it make the following calls using the SOAFaces API at the beginning of the very first task: JobDependencyRule depRule = jobContext.getDependencyRule("JobA One at a Time"); depRule.setJobSchedulingSuspended(); //this will prevent any job associated with this //rule from being scheduled (including other instances of JobA) 5) Now when job A is at the end of its task processing, have it make the following calls using the SOAFaces API: JobDependencyRule depRule = jobContext.getDependencyRule("JobA One at a Time"); depRule.setJobSchedulingAllowed(); //this will allow a job associated with this rule to run //if the job's schedule also allows it to run
Modifier and Type | Method and Description |
---|---|
boolean |
isJobSchedulingAllowed(java.util.Calendar referenceTime)
Checks if the dependency rule is satisfied or not.
|
void |
setJobSchedulingAllowed()
Allowing job scheduling on a dependency rule will allow a job,
that is associated to this dependency rule, to run normally.
|
void |
setJobSchedulingAllowed(java.util.Calendar start,
java.util.Calendar end)
Allowing job scheduling on a dependency rule will allow a job,
that is associated to this dependency rule, to run normally only
within the start and end time ranges provided.
|
void |
setJobSchedulingSuspended()
Suspending job scheduling on a dependency rule will prevent a job,
that is associated to this dependency rule, from being scheduled regardless
of what the jobs schedule.
|
boolean isJobSchedulingAllowed(java.util.Calendar referenceTime)
true
if dependency rule allows jobs to run relative to the
given referenceTime
, false
means
the job will not be permitted to run on the given referenceTime
.void setJobSchedulingSuspended()
void setJobSchedulingAllowed()
void setJobSchedulingAllowed(java.util.Calendar start, java.util.Calendar end)
start
- the start date at which the rule will
allow for a job to be scheduled. null
means start date range extends infinitly into the past.end
- the end date at which the rule will
allow for a job to be scheduled. null
means expire date range extends infinitly into the future.Copyright © Grand Logic, Inc. All Rights Reserved.