mirzaei
mirzaei

Reputation: 363

Quartz StatefulJob / non-StatefulJob

Would you please explain to me the exact mean of the StatefulJob in quartz and it's difference with none StatefulJob?

Upvotes: 8

Views: 12716

Answers (3)

user3377322
user3377322

Reputation: 3

jobDetail.getJobDataMap().put("type","FULL");

This line is will decide we are using statefull or non-statefull.

  1. If we are passing the argument then it will be statefull.
  2. With out statefull there is no way to pass the arguments in execute method
  3. In state full while execution time if we modify any value then the execution job will be lost it wont re-triggered at simultaneous process time.
  4. Only one job will execute at a time the second will be sleep until the first one is completed.
  5. In multi scheduling process the second job argument will be share to first job at run time. this is one type of disadvantage in multi scheduling process.

Upvotes: 0

user1567615
user1567615

Reputation: 188

StatefulJob interface, provides 2 things,

first: only one job will be run any time

second: in (SimpleTriggerBean) you will not worry about your job running duration. it means that the next run will be done after delay time after ending of previous one.

Upvotes: 13

Rosdi Kasim
Rosdi Kasim

Reputation: 26036

StatefulJob guarantees only one job will be running at one time. For example, if you schedule your job to run every 1 minute, but your job took 5 minutes to complete, then the job will not be run again until the previous job has completed.

This is useful to make sure there is only one job running at any given time.

The next job will be run on the next schedule, not immediately after the previous job completed.

Upvotes: 3

Related Questions