Quartz StatefulJob / non-statefulJob

Could you explain to me the exact value of StatefulJob in quartz, and this is no different from any StatefulJob?

+6
source share
3 answers

StatefulJob interface, provides 2 things,

first: only one task will be performed at any time

second: in (SimpleTriggerBean), you will not worry about the duration of the work. this means that the next run will be executed after a delay after the end of the previous one.

+11
source

StatefulJob guarantees that only one job will be launched at a time. For example, if you plan your work to work every 1 minute, but your work took 5 minutes, then the task will not be started again until the completion of the previous task.

This is useful to ensure that only one task is running at any given time.

The next task will be launched in the next schedule, and not immediately after the completion of the previous task.

+2
source
jobDetail.getJobDataMap().put("type","FULL"); 

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

  • If we pass an argument, it will be statefull.
  • There is no way with statefull to pass arguments in the execute method
  • In the state filled at runtime, if we change any value , then the execution task will be lost, it will not be restarted simultaneously with the process.
  • Only one task will be performed at a time, while the second will sleep until the first is completed.
  • During multiple scheduling, the second job argument will be common to the first job at run time. this is one of the shortcomings in the multiple planning process.
0
source

Source: https://habr.com/ru/post/922625/


All Articles