Hi,
I want to configure a recurring job through hangfire, i have already created my job folloiwng the approach mentioned in following link.
https://aspnetboilerplate.com/Pages/Documents/Background-Jobs-And-Workers#create-a-background-job
I can call it from application service using following code, _backgroundJobManager.Enqueue<MortgageStatusService, int>(1);
May i know how i can configure it at the start of application so that it executes after every 15 minutes?
public class MortgageStatusService : BackgroundJob<int>, ITransientDependency { private readonly IRepository<CarMortgage> _carMortgageRepository; private readonly IRepository<CarMortgageLog> _carMortgageLogRepository; private readonly IUnitOfWorkManager _unitOfWorkManager;
public MortgageStatusService(
IRepository<CarMortgage> carMortgageRepository,
IRepository<CarMortgageLog> carMortgageLogRepository,
IUnitOfWorkManager unitOfWorkManager)
{
_carMortgageRepository = carMortgageRepository;
_carMortgageLogRepository = carMortgageLogRepository;
_unitOfWorkManager = unitOfWorkManager;
}
[UnitOfWork]
public override void Execute(int args)
{
SynchronizeData.Synchronize(_carMortgageRepository, _carMortgageLogRepository);
}
}
4 Answer(s)
-
0
You can configure it in module's
PostInitialize
. -
0
that i figured out but i want to know the syntax to configure a job to run after every 15 minutes.
-
0
http://docs.hangfire.io/en/latest/background-methods/performing-recurrent-tasks.html
-
0
I managed to schedule it in PostInitialize using following code.
RecurringJob.AddOrUpdate<MortgageStatusService>("Synchrnize-With-xxxxxxxx", x => x.Execute(1) , Cron.MinuteInterval(15));