We left Russia. We are against aggression and war with Ukraine. It is a tragedy for our nations, it is a nightmare

Requeing a Job with time delay

Can we have a feature where we can get HangFire to requeue a job with time delay?

So basically something with a signature like this: bool BackgroundJob.Requeue(string jobId, timespan delay).

The use case for this is when an error code 429 gets sent back (too many requests), it would be nice if we could let it fire again with the exact same state after a delay to allow the target server to cool down a bit.

As I’m writing this, I realized I could maybe use Sleep(), but I don’t really know if that’s the best way to tackle something like this.

Thanks!

That means the server is too busy. You could get that response for a week straight. Hangfire already has a sliding time increase on its retries. The question is what happens if all 10 retries fail due to error code 429. Is it ok if the job never succeeds?

There are a number of factors here. If you need to guarantee this job succeeds I would suggest catching the error and waiting (i.e., Sleep()).

This is kind of specific to this one sever we’re looking to integrate with. It uses Rate Limiting to make sure its servers doesn’t get too crowded, so it throttles requests for 30 seconds if ever it receives too much from a given integrator.

So in our side we just have to re-run the job after 30 seconds. I guess using Sleep() would be fine though, it just makes the implementation a bit more complicated to write.

But anyways thanks for the info! Also thanks for Hangfire it’s been a blessing!

EDIT: Was multitasking and auto-piloted sending the reply.