From 5ac1d0c9fd931f6ce7bef8919c769dc2d6e4fc3d Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Wed, 15 Aug 2018 15:37:14 +0300 Subject: [PATCH] Add initial background jobs doc. --- docs/Background-Jobs.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 docs/Background-Jobs.md diff --git a/docs/Background-Jobs.md b/docs/Background-Jobs.md new file mode 100644 index 0000000000..12e0dbbeea --- /dev/null +++ b/docs/Background-Jobs.md @@ -0,0 +1,23 @@ +## Background Jobs + +### Introduction + +Background jobs are used to queue some tasks to be executed in the background. You may need background jobs for several reasons. Here are some examples: + +- To perform **long-running tasks** without having the users wait. For example, a user presses a 'report' button to start a long-running reporting job. You add this job to the **queue** and send the report's result to your user via email when it's completed. +- To create **re-trying** and **persistent tasks** to **guarantee** that a code will be **successfully executed**. For example, you can send emails in a background job to overcome **temporary failures** and **guarantee** that it eventually will be sent. That way users do not wait while sending emails. + +Background jobs are **persistent** that means they will be **re-tried** and **executed** later even if your application crashes. + +ABP provides an **abstraction** module and **several implementations** for background jobs. It has a built-in/default implementation as well as Hangfire and RabbitMQ integrations. + +### Abstraction Module + +TODO + +### Creating a Background Job + +A background job is a class that implements the `IBackgroundJob` interface or derives from the `BackgroundJob` class. `TArgs` is a simple plain C# class to store the job data. + +An example background job to send emails in background: +