Quartz 后台作业管理

    建议使用ABP CLI安装包.

    如果你想手动安装;

    1. 添加 NuGet包添加到你的项目:

    Quartz是一个可配置的类库,对此ABP框架提供了 AbpQuartzOptions. 你可以在模块预配置此选项,ABP在初始化Quartz模块时将使用它. 例:

    1. [DependsOn(
    2. //...other dependencies
    3. typeof(AbpBackgroundJobsQuartzModule) //Add the new module dependency
    4. )]
    5. public class YourModule : AbpModule
    6. {
    7. {
    8. var configuration = context.Services.GetConfiguration();
    9. PreConfigure<AbpQuartzOptions>(options =>
    10. {
    11. {
    12. ["quartz.jobStore.dataSource"] = "BackgroundJobsDemoApp",
    13. ["quartz.jobStore.type"] = "Quartz.Impl.AdoJobStore.JobStoreTX, Quartz",
    14. ["quartz.jobStore.tablePrefix"] = "QRTZ_",
    15. ["quartz.serializer.type"] = "json",
    16. ["quartz.dataSource.BackgroundJobsDemoApp.connectionString"] = configuration.GetConnectionString("Quartz"),
    17. ["quartz.dataSource.BackgroundJobsDemoApp.provider"] = "SqlServer",
    18. ["quartz.jobStore.driverDelegateType"] = "Quartz.Impl.AdoJobStore.SqlServerDelegate, Quartz",
    19. };
    20. });
    21. }

    Quartz默认将作业与调度信息存储在内存中,示例中我们使用选项模式的预配置将其更改为存储到数据库中. 有关Quartz的更多配置请参阅.

    你可以通过 AbpBackgroundJobQuartzOptions 选项自定义异常处理策略:

    1. //...other dependencies
    2. typeof(AbpBackgroundJobsQuartzModule) //Add the new module dependency
    3. )]
    4. public class YourModule : AbpModule
    5. {
    6. public override void ConfigureServices(ServiceConfigurationContext context)
    7. {
    8. Configure<AbpBackgroundJobQuartzOptions>(options =>
    9. {
    10. options.RetryStrategy = async (retryIndex, executionContext, exception) =>
    11. {
    12. // customize exception handling
    13. };
    14. });
    15. }