Hi,
I have a recurring job configured to run every minute. But I need that, if it’s time to trigger the job again and the last one haven’t finished yet, Hangfire waits it to finish before trigger the new one.
There is some way to do that?
Hi,
I have a recurring job configured to run every minute. But I need that, if it’s time to trigger the job again and the last one haven’t finished yet, Hangfire waits it to finish before trigger the new one.
There is some way to do that?
I just found this project, and need to do something similar. I need a recurring process that runs every minute. However, I do not want more than one running at any one time. I’ve been playing around with this solution involving two jobs: a single recurring job (“Should_I_queue_worker”); and another job that runs immediately(“Worker”):
It certainly isn’t bulletproof, but in my testing it fulfills my needs - until this feature becomes available.
There are a couple of other methods:
Use the DisableConcurrentExecution attribute which creates a distributed lock. The second job will be blocked until the first completes. Please note that this blocked job will “consume” a worker.
Write a custom attribute / state change handler similar to the DisableConcurrentExecution attribute which upon failing to get a distributed lock after an instant timeout, sets the job to Succeeded. (Or failed)
See:
Thanks, yngndrw. I knew there had to be a more elegant (and robust) way to handle long-running recurring jobs. I’ll play around with your suggestions and post my results.
Hello Martin,
Did that solution work with your case?