3

Is the sole factor in Quartz determining if a job is successful is if the job's Execute() method completes without having thrown a JobExecutionException?

This is the assumption I've been working under; so if I wire up a listener to my job and the jobException parameter == null in JobWasExecuted(...) then I am assuming Quartz considers that job to be successful.

I am asking because I have seen others check the TriggerState from within JobWasExecuted(...) and if it is TriggerState.COMPLETE, they appear to be considering the job successful. But that is just checking the state of the trigger itself, not the job, correct? If that is the case, does a TriggerState of COMPLETE simply mean that the trigger has fired?

So two things I am looking to confirm:

  1. Lack of a thrown JobExecutionException inside a job's Execute method (and hence null in the listener) means (to Quartz) that the job completed successfully

and

  1. TriggerState is not an indicator of job completion success
Howiecamp
  • 2,981
  • 6
  • 38
  • 59

1 Answers1

3

What a job being successful will depend on how you write the job. For example, we have a job that does something for each of our clients. It's designed however to continue even if there is an exception or an issue while doing work for one client. In other cases, you might want the job to fail as a unit. So, it depends mostly on how you write your job. However, the JobWasExecuted will be called on your job listener when the job has finished executing. Then it would be up to you to determine what success or failure means. If you wrote your job to throw an exception if it was unsuccessful, then the answer to 1 would be yes.

Trigger state is not a good indicator of whether the job completed successfully, for the above reasons.

jvilalta
  • 6,679
  • 1
  • 28
  • 36
  • << However, the JobWasExecuted will be called on your job listener when the job has finished executing. Then it would be up to you to determine what success or failure means. >> Agreed, I would make that determination from a business logic point of view, but am I correct in understanding that Quartz itself considers a job to be successful/completed if the job's Execute() method returns without an exception? It's Quartz's point of view that I am most interested in. – Howiecamp Jul 06 '15 at 16:08