Question

This link suggests to create an abstract base class that can read the job data map information for Quartz.net and each of the jobs will derive from this base class.

http://quartznet.sourceforge.net/faq.html#howtochainjobs

Can someone provide me a sample of this base class because I am not sure how to retrieve the job details in the base class and then call the Execute method on the derived class?

Pratik

Was it helpful?

Solution

Creating an abstract base class is just a suggestion made by the Quartz.NET documentation, and is not a requirement for implementing job chaining. Basically they are suggesting that if you want to chain jobs: "AJob" -> "BJob" -> "CJob", you would do something along the lines of this:

  1. Create abstract class "ChainBaseJob".

  2. Make your job class (which both AJob and BJob are types of) inherit from ChainBaseJob.

  3. ChainBaseJob would contain some sort of method like:

        string GetNextJobInChain()
    

...which would return the name of the job (meaning the Quartz job name). There's a variety of ways to do use this, but I guess the documentation is suggesting that your TriggerListener checks to see (during the job completed method) if a completed job (let's say "AJob") inherits from ChainBaseJob. If it does, it will cast it and call GetNextJobInChain, and use the name returned by the method to call the scheduler to execute it upon completion of AJob. If everything is implemented correctly, the TriggerListener will know to execute BJob, after AJob completes.

Good luck.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top