Finally, In the last endpoint, we want to send special offers monthly basis for that we use a recurring job that will execute continuously in the background after specified Cron conditions.įinally, let’s configure things in Program.cs Class related to Hangfire like SQL Server Database and middleware which we need. When the user completes the process then it will get an email immediately using Fire-and-Forget Job and later on when this job is executed the Continuation job will get executed which is the child job and executed after the parent job will get executed. In the third endpoint, we created a job for payment. That when the user adds a new product to the checklist it will get notified and reminded after a few seconds like you are adding a new product to your checklist. After that, we created another endpoint related to the product checklist.Here we created different endpoints based on product scenarios like when a user login to the shopping site it will get a welcome message on an immediate basis using fire and forget job.RecurringJob.AddOrUpdate(() => Console.WriteLine("Sent similar product offer and suuggestions"), Cron.Daily) Recurring Job - this job is executed many times on the specified cron schedule Return "You have done payment and receipt sent on your mail id!" Continuations Job - this job executed when its parent job is executed.īackgroundJob.ContinueJobWith(parentjobId, () => Console.WriteLine("Product receipt sent!")) Var parentjobId = BackgroundJob.Enqueue(() => Console.WriteLine("You have done your payment suceessfully!")) Fire and Forget Job - this job is executed only once You added one product into your checklist successfully!" Var jobId = BackgroundJob.Enqueue(() => Console.WriteLine("Welcome to Shopping World!")) Fire - and - Forget Job - this job is executed only once Public class ProductController : ControllerBase NET Framework 6, Configure HTTPS and enable Open API support and swaggerĬreate API Controller and name it as ProductController using Hangfire Provide the Project name HangfireDemo and then provide the locationĪlso, provide additional information like. Open Visual Studio 2022 and create a new. There are also two jobs present now in Hangfire one is Batch Job and another is Batch Continuation but these are present in the Hangfire Pro version and which are used to execute multiple jobs in batch as a single entity. Recurring Job is executed many times after specified condition and time intervalĬontinuation job is executed when its parent job is executed and finished. We will look at that one by oneįire and Forget jobs are executed only one time after certain conditions which we provideĪ delayed job is also, execute only once but after a specific interval of time. There are different types of jobs that are present in the Hangfire.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |