We started thinking about "Only one should run at any point of time" requirement. Luckily there is a simple and smart way to achieve this. Declare the job as "Stateful".
if a job is stateful, and a trigger attempts to 'fire' the job while it is already executing, the trigger will block (wait) until the previous execution completes.
You 'mark' a Job as stateful by having it implement the StatefulJob interface, rather than the Job interface.
public class sampleJob
extends QuartzJobBean
implements StatefulJob
{
protected void executeInternal(final JobExecutionContext _ctx)
throws JobExecutionException
{
// Do the job here
}
}
No comments:
Post a Comment