Manual Retry a Job ( not from dashboard )

dashboard
Tags: #<Tag:0x00007f7833fa57c8>

#1

Hello, i am new to Hangfire and loved it so far, but i am having difficulties to find a guide nor a post to solve my problem.

I already managed to automatically send an email to our dev email when a job is failed thanks to this post : Enqueue a new job if last retry fail

But i am trying to put a button to restart the failed background job via our application’s Log Dashboard, functioning just like the hangfire dashboard’s failed page retry button,
and i can’t find the source code to do so.


#2

i found the Requeue method from backgroundjobclient and intended to use it to retry the failed jobs manually, but is this the correct practice ? i am trying it anyway.

Please correct me if i am wrong.


#3

It is, in as much as I can deduce from your original post. But take care there are a number of possible caveats depending on your particular implementation.

What you have to realize is that the a requeue results (pardon if my terminology here is incorrect) instantiates the job again from the machine that executes the ‘requeue’.

This can have unexpected results if you don’t keep it in mind and use things like maybe environment variables or custom filters that do (just an example).


#4

thank you for the valueable insight.
another thing that i want to make sure is,
if i make fixes or changes in the method (without changing method parameters), and i requeue the failed job, it will run the new method with same parameter values right ?

but if i make changes to method parameters, then that failed job should not be requeued, and this is one of the things i have to be careful about.


#5

Job parameters are persisted in the repo/store … So a requeue would just reuse the old parameters. Again this is default behavior. Since Hangfire can be customized in any number of methods it again depends on what/how you implemented it.

I suppose you could change the persisted parameters in the repo with something like an SQL command (or equivalent for your DB of choice) and then requeue but it is something I would personally avoid. That being said I am sometimes forced to manually correct some things in my repo if for instance there was a crash or DB issue. But that is exceptional and not routine.


#6

thank you ! i am clear about this now. admin can close this topic.