mirror of https://github.com/abpframework/abp
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
73 lines
3.0 KiB
73 lines
3.0 KiB
# Quartz Background Job Manager
|
|
|
|
[Quartz](https://www.quartz-scheduler.net/) is an advanced background job manager. You can integrate Quartz with the ABP Framework to use it instead of the [default background job manager](Background-Jobs.md). In this way, you can use the same background job API for Quartz and your code will be independent of Quartz. If you like, you can directly use Quartz's API, too.
|
|
|
|
> See the [background jobs document](Background-Jobs.md) to learn how to use the background job system. This document only shows how to install and configure the Quartz integration.
|
|
|
|
## Installation
|
|
|
|
It is suggested to use the [ABP CLI](CLI.md) to install this package.
|
|
|
|
### Using the ABP CLI
|
|
|
|
Open a command line window in the folder of the project (.csproj file) and type the following command:
|
|
|
|
````bash
|
|
abp add-package Volo.Abp.BackgroundJobs.Quartz
|
|
````
|
|
|
|
### Manual Installation
|
|
|
|
If you want to manually install;
|
|
|
|
1. Add the [Volo.Abp.BackgroundJobs.Quartz](https://www.nuget.org/packages/Volo.Abp.BackgroundJobs.Quartz) NuGet package to your project:
|
|
|
|
````
|
|
Install-Package Volo.Abp.BackgroundJobs.Quartz
|
|
````
|
|
|
|
2. Add the `AbpBackgroundJobsQuartzModule` to the dependency list of your module:
|
|
|
|
````csharp
|
|
[DependsOn(
|
|
//...other dependencies
|
|
typeof(AbpBackgroundJobsQuartzModule) //Add the new module dependency
|
|
)]
|
|
public class YourModule : AbpModule
|
|
{
|
|
}
|
|
````
|
|
|
|
## Configuration
|
|
|
|
Quartz is a very configurable library,and the ABP framework provides `AbpQuartzPreOptions` for this. You can use the `PreConfigure` method in your module class to pre-configure this option. ABP will use it when initializing the Quartz module. For example:
|
|
|
|
````csharp
|
|
[DependsOn(
|
|
//...other dependencies
|
|
typeof(AbpBackgroundJobsQuartzModule) //Add the new module dependency
|
|
)]
|
|
public class YourModule : AbpModule
|
|
{
|
|
public override void PreConfigureServices(ServiceConfigurationContext context)
|
|
{
|
|
var configuration = context.Services.GetConfiguration();
|
|
|
|
PreConfigure<AbpQuartzPreOptions>(options =>
|
|
{
|
|
options.Properties = new NameValueCollection
|
|
{
|
|
["quartz.jobStore.dataSource"] = "BackgroundJobsDemoApp",
|
|
["quartz.jobStore.type"] = "Quartz.Impl.AdoJobStore.JobStoreTX, Quartz",
|
|
["quartz.jobStore.tablePrefix"] = "QRTZ_",
|
|
["quartz.serializer.type"] = "json",
|
|
["quartz.dataSource.BackgroundJobsDemoApp.connectionString"] = configuration.GetConnectionString("Quartz"),
|
|
["quartz.dataSource.BackgroundJobsDemoApp.provider"] = "SqlServer",
|
|
["quartz.jobStore.driverDelegateType"] = "Quartz.Impl.AdoJobStore.SqlServerDelegate, Quartz",
|
|
};
|
|
});
|
|
}
|
|
}
|
|
````
|
|
|
|
Quartz stores job and scheduling information **in memory by default**. In the example, we use the pre-configuration of [options pattern](Options.md) to change it to the database. For more configuration of Quartz, please refer to the Quartz's [documentation](https://www.quartz-scheduler.net/documentation/quartz-3.x/tutorial/index.html). |