I am using Quartz.net to schedule various API calls. The API I am using restricts the number of requests that can be made per time period and if that is exceeded, then my account is penalized for the next minute (no requests can be made).
If I ever receive a notification that I have made too many requests and my account will be throttled for the next minute, I will need to ensure that no scheduled jobs fire during that period. How can I best delay firing of all scheduled jobs by a minute or two?
I was originally intending to call Scheduler.GetTriggerKeys() and loop over and update every existing trigger like so:
foreach(var triggerKey in SchedInstance.GetTriggerKeys(GroupMatcher<TriggerKey>.AnyGroup()))
{
var oldTrigger = SchedInstance.GetTrigger(triggerKey);
TriggerBuilder tb = oldTrigger.GetTriggerBuilder();
// Update the schedule associated with the builder and build the new trigger
tb.StartAt(oldTrigger.StartTimeUtc.AddSeconds(63));
var newTrigger = tb.Build();
SchedInstance.RescheduleJob(oldTrigger.Key, newTrigger);
}
Is this the right approach or would it be better to simply stop the scheduler for the same time period and then restart it?