Hi,
using: Core, MVC, jQuery project - v7.2.2
We wish to implement Hangfire in a project - but have som questions :-)
Need a background job running for each tenant - on a scheduled basis. (RecurringJob.AddOrUpdate) Should always be running - that is when the web site starts, the job should be "created" and start running. So no "manual" trigger to start job.
In the ....Web.Core project
- Webconst - HangfireDashboardEnabled set to true
- In this project should I uncomment "Configureation.BackgroundJobs.UseHangfire() in the ... WebCoreModule?
In the ...Web.Host project
- Startup.cs - no changes made - it is checking the WebConst HangfireDashboardEnabled - OK?
**In the ...Web.Mvc project **
- Startup.cs - no changes made - it is checking the WebConst HangfireDashboardEnabled - OK?
Defining / starting the Hangfire job From searching I can see that often jobs are created / started in the PostInitialize - eg. in ...WebMvcModule of the ...Web.Mvc project Is this the correct approach?
Or should we make a new controller? and then how do we trigger the job?
Should we create a class like below - based on BackgroundJob - and make an Execute method?
public class TestStatusService : BackgroundJob<int>, ITransientDependency
hoping for some "best practice" input :-)
6 Answer(s)
-
0
Hi,
Did you check https://aspnetboilerplate.com/Pages/Documents/Hangfire-Integration ?
-
0
Hi ismcagdas
yes we did :-)
but do you have any best-practice for creating the jobs - where to initialize them (PostInitialize or...) and if we should use class based on BackgroundJob<>
-
0
You can use background job as you normally would. https://aspnetboilerplate.com/Pages/Documents/Background-Jobs-And-Workers
For example you can check ImportUsersToExcelJob
-
0
@deltavision, See getting hangfire to work in zero
-
0
@bobingham,
thank you - works perfectly :-)
-
0
Glad to be of help.