Unstable state of quartz
I am looking into the Quartz Task Scheduler framework (using version 1.5.2 in jboss 5.1). I am trying to understand the difference between stateful and non-stateful.
It is documented that any changes made to the JobDataMap during job execution will not persist for the next job execution for non-stationary jobs, but the same will persist across stateful jobs.
To test the above, I wrote a non-normative work in which the JobDataMap changes while the job is running. According to the above logic, changes should not be persisted or made available the next time the job is executed. However, it looks like the changes persist across the job.
Here is the job class:
public class QuartzTask implements Job{
@Override
public void execute(JobExecutionContext arg) throws JobExecutionException {
// TODO Auto-generated method stub
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(Calendar.getInstance().getTime());
System.out.println(arg.getTrigger().getName()+" task executed:"+timeStamp);
System.out.println("before put:"+arg.getMergedJobDataMap().get("data"));
arg.getJobDetail().getJobDataMap().put("data", "added");
System.out.println("after put:"+arg.getMergedJobDataMap().get("data"));
}
}
If I run the above task 2 times, then the output should look like this:
before put: null
after put: added
before put: null
after put: added
However, the output looks like this:
before put: null
after put: added
before put: added
after put: added
What am I missing here that is causing this behavior?
source to share
No one has answered this question yet
Check out similar questions: