I have a process that does something every 30 seconds. I make a check for the last four reports on every report and see if I need to schedule a job for every 5 minutes. If I do - I use this:
RecurringJob.AddOrUpdate(jobId, expression, "*/5 * * * *");
I also check whether I need to stop the background job. If so, I call this:
However the problem is that for every report that requires me to continue do background processing I get the expression executed. Consider the following sequence (for reports requiring background processing):
R1, R2, R3, R4, R5 ^--- this is where I start schedule the job to be executed in 5 minutes
After some time I need to trigger the background job (because it needs to be run every 5 minutes)
v---- the background job here is already triggered at R4 ... R7, R8, R9, R10, R11, R12 ^---- this is where the job actually gets triggered
So the problem is this: I get
expression executed for every report since scheduling the job until it actually needs to be triggered (so from
R4 every report generates an expression call).
So my question is this: is
AddOrUpdate idempotent with regards to the
jobId or does it add invocation to the queue that gets executed once the time comes?