Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between Hangfire background job and recurring job?

In Hangfire, what is the difference between a Background job and a recurring job? Because cron support is provided only in recurring job and not in background job?

like image 640
user2613228 Avatar asked Jan 16 '15 14:01

user2613228


People also ask

Where does hangfire store recurring jobs?

Where does HangFire store recurring jobs? Persistent. Background jobs are created in a persistent storage – SQL Server and Redis supported officially, and a lot of other community-driven storages. You can safely restart your application and use Hangfire with ASP.NET without worrying about application pool recycles.

What are hangfire jobs?

Hangfire is an open-source framework that can be used to perform background processing in . Net and . Net Core applications. It is mainly used to perform background tasks such as batch/email notification, batch import of files, video/image processing, database maintaining, file purging, etc.

How do I stop a recurring job on hangfire?

You can remove an existing recurring job by calling the RemoveIfExists method. It does not throw an exception when there is no such recurring job. RecurringJob. RemoveIfExists("some-id");

Is hangfire reliable?

Hangfire is open-source and used to schedule the job at a particular event and time. It is also used to create, process, and manage your background jobs. Basically, we use this in Background Processing without user intervention. Hangfire is reliable and persistent.


1 Answers

Recurring job is meant to trigger in certain intervals i.e. hourly, daily, thus you supply a cron expression.

RecurringJob.AddOrUpdate(
    () => YourRegularJob(), 
    Cron.Daily);

Background job is meant to execute once, either by placing it in the queue and executing immediately or by delaying the job to be executed at specific time.

BackgroundJob.Enqueue(
    () => YourImmediateJob());

BackgroundJob.Schedule(
    () => YourDelayedJob(), 
    TimeSpan.FromDays(3));
like image 123
Jerry Avatar answered Oct 23 '22 03:10

Jerry