0

I've got a series of Quartz.Net jobs chained together using Listeners:

  • Job A executes...
    • JobAListener.JobWasExecuted() method is called, then executes Job B
  • Job B executes...
    • JobBListener.JobWasExecuted() method is called, then executes Job C
  • and so on...

Let's say Job A fails in such a way that I don't want to refire the job and I want to short-circuit the remainder of the job chain. In otherwords, I want to stop execution of the rest of the chain after Job A fails.

What's the proper means of doing this?

Howiecamp
  • 2,981
  • 6
  • 38
  • 59

1 Answers1

2

The JobWasExecuted() method on your job listener should be taking an IJobExecutionContext and a JobExecutionException as parameters provided by Quartz. I would just check to see if the JobExecutionException is null when JobWasExecuted() is triggered for JobA. If it is not null, than you know an unhandled exception occurred while firing JobA and you can simply not fire JobB. This in effect will "short circuit" the calling chain.

This assumes that an unhandled exception is your criteria for determining if JobA failed (you didn't specify). If it something beyond this that you need to inspect, you can always look at properties of the IJobExecutionContext to get more info.

Chris Knight
  • 1,448
  • 1
  • 15
  • 21