Question

I am looking at Quartz in combination with Atlas for a scheduled service. I have a program that runs once a day (scans my mailbox for a specific mail). If there is a result I want it to run again the next day. If there are no results, the job should execute again in let's say 15 minutes. The reason for this is because the mail does not always arrive on time.

Was it helpful?

Solution

What if you just run the job with a fixed schedule, say every fifteen minutes and your logic keeps track of the last successful retrieval date?

Then wen your job starts it could check that last successful date is today and just the skip the logic of mailbox scan.

Scheduling a new trigger is always also possible if you want the more complicated (harder to track) version.

  • After unsuccessful run, schedule a new trigger to run once at DateTime.UtcNow.AddMinutes(15)
  • After successful run just schedule a trigger with start date of tomorrow

You can access the scheduler from you job via scheduling context for the trigger scheduling purposes. If you server goes down you probably need to know whether you have loaded the data already when it restarts. That might support the first simpler approach.

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