Fire and forget Job execution timeout


#1

Hello,
I’m very interested in using Hangfire in our project and I was wondering if there is an execution timeout when executing a “Fire and forget” job type.
If the job is not finished in a certain elapse of time is it stopped by Hangfire ?
Thank you for your answer.
Best regards,
Victor


#2

Hello everyone,
As I haven’t received any answers maybe be I can explain more about what we are trying to accomplish.
The idea is to launch a fire and forget job which starts an event subscription that awaits for new incoming messages coming from an external source.
The job will run indefinitely and can be stopped manually or when the host service is stopped. We can have several subscriptions in parallel on different sources which can be added dynamically via a http request to a web API.
We were thinking about having a job per subscription and manage it via a fire and forget job?
We also know that hangfire provides the IBackgroundProcess interface for implementing long running tasks but if I understand correctly the background process are initiated at the job creation and there is no way of adding background processes dynamically at each subscription request for example? Is it right?
So that’s the reason of my first question is there a timeout in executing a fire and forget job? Or the job can run indefinitely?
Thanks everyone for reading and answers.
Best regards,
Victor


#3

The short answer, is no. If you wanted hangfire to stop your job, you would need to make your job cancelable. And if you’re doing that, then just take care of the timeout within your job itself


#4

Use CancellationToken in your job.


#5

Hello,
@hometoast thanks for message this answers my question I wanted to be sure that there is no internal hangfire timeout that stops the job automatically.
Thanks @bigB we are using CancellationToken to control job stop for example during service stop.