Is there any way to change the scheduling of a recurring job while the Web API Hangfire is running?
– I tried adding a rest contract that accepts a jobid and new cron schedule, but there is no method that can just adjust the cron schedule, I always need a reference to the job?
Is there any way I can add jobs to an already running Web API Hangfire, through adding a .dll in a folder somewhere or?
Seeing as I can’t edit my post (“Body is too similar to what you recently posted”) I will add my edits here.
I’m currently looking into Hangfire to schedule a lot of recurring jobs (using cron) with. And I have a couple of questions. I will be using the latest version, together with a ASP.NET Core Web API application.
What way does everyone use to schedule their jobs when their application starts? Does everyone just put a ton of RecurringJob.AddOrUpdate in their StartUp?
Is there any way to change the scheduling of a recurring job while the application is running?
– I tried adding a rest contract that accepts a jobid and new cron schedule, but there is no method that can just adjust the cron schedule, I always need a reference to the job (this isn’t ideal when you have a lot of jobs)?
Is there any way I can add jobs to an already running application like for example through adding a .dll in a folder somewhere?
Is there an example application somewhere available that has some advanced scheduling / jobs?
I am not sure what you are asking here. As far as I know you can’t dynamically add code to a .Net program during runtime, but maybe with some blackmagic it is possible. Question is, why would you?
The first issue you will have is that the Hangfire server has to have access to all the needed references of the jobs it runs. The Hangfire dashboard will also be a little pissy if it doesn’t have the needed references, but it will only be display errors and nothing else.
Normally we just deploy a new version of the Hangfire server and Hangfire client at the same time, and it mostly goes over with no issues. Unless you changed something in the code so the jobs that currently enqueued can’t be executed anymore.
Otherwise yes you can run all of them in the same project if you want. In my current setup it is all run as two separate projects, the dashboard and the server(s). But the way the clients are setup is a complete mess, that makes me want to hit former co-works with a very big hammer.
If it wasn’t for the ease of deployment of web projects though, I would have made the Hangfire servers run as Windows Services instead. Making the Hangfire servers run on an IIS server is just really annoying and seems to cause me a lot of weird issues. I have learned about Topshelf since though, so I plan to look into it if I ever get time to try the MAMQ workaround extension or the 5 year old Hangfire bug is fixed.