Open Closed

Quartz integration for background workers #10488


User avatar
0
sserestyen created

Hi,

I use the commercial license with version 9.3.7.

I wanted to add the Quartz integration following the documentation https://abp.io/docs/latest/framework/infrastructure/background-workers/quartz I run below command to add the Quartz integration to the HttpApi.Host project abp add-package Volo.Abp.BackgroundWorkers.Quartz

I also have added below as a dependency for HttpApiHostModule typeof(AbpBackgroundWorkersQuartzModule)

After these when I run the project, I get below exception during application start:

Host terminated unexpectedly! Volo.Abp.AbpInitializationException: An error occurred during the initialize Volo.Abp.Modularity.OnApplicationInitializationModuleLifecycleContributor phase of the module Volo.Abp.AuditLogging.AbpAuditLoggingApplicationModule, Volo.Abp.AuditLogging.Application, Version=9.3.7.0, Culture=neutral, PublicKeyToken=null: Unexpected end of expression.. See the inner exception for details. ---> System.FormatException: Unexpected end of expression. at Quartz.CronExpression.BuildExpression(String expression) at Quartz.CronExpression..ctor(String cronExpression) at Quartz.CronExpression.ValidateExpression(String cronExpression) at Quartz.CronScheduleBuilder.CronSchedule(String cronExpression) at Quartz.CronScheduleTriggerBuilderExtensions.WithCronSchedule(TriggerBuilder triggerBuilder, String cronExpression) at Volo.Abp.BackgroundWorkers.Quartz.QuartzPeriodicBackgroundWorkerAdapter1.BuildWorker(IBackgroundWorker worker) at Volo.Abp.BackgroundWorkers.Quartz.QuartzBackgroundWorkerManager.ReScheduleJobAsync(IBackgroundWorker worker, CancellationToken cancellationToken) at Volo.Abp.BackgroundWorkers.Quartz.QuartzBackgroundWorkerManager.AddAsync(IBackgroundWorker worker, CancellationToken cancellationToken) at Volo.Abp.AuditLogging.AbpAuditLoggingApplicationModule.OnApplicationInitializationAsync(ApplicationInitializationContext context) at Volo.Abp.Modularity.OnApplicationInitializationModuleLifecycleContributor.InitializeAsync(ApplicationInitializationContext context, IAbpModule module) at Volo.Abp.Modularity.ModuleManager.InitializeModulesAsync(ApplicationInitializationContext context) --- End of inner exception stack trace --- at Volo.Abp.Modularity.ModuleManager.InitializeModulesAsync(ApplicationInitializationContext context) at Volo.Abp.AbpApplicationBase.InitializeModulesAsync() at Volo.Abp.AbpApplicationWithExternalServiceProvider.InitializeAsync(IServiceProvider serviceProvider) at Microsoft.AspNetCore.Builder.AbpApplicationBuilderExtensions.InitializeApplicationAsync(IApplicationBuilder app)`

As I understand, there is a cron expression somewhere in the AbpAuditLoggingApplicationModule, which is not valid for Quartz, but I do not have access to the pro version of the source code, therefore could not verify that.

Could you advise which configuration needs to be changed to get this running?

Thanks,.


4 Answer(s)
  • User Avatar
    0
    AI-Bot created
    Support Team ABP Agent
    • Your stack trace shows Quartz is trying to build a Cron trigger for a periodic worker during AbpAuditLoggingApplicationModule.OnApplicationInitializationAsync, and it fails with System.FormatException: Unexpected end of expression. coming from Quartz.CronExpression.
    • That error happens when the cron string passed to Quartz is not a valid Quartz cron (Quartz expects 6–7 fields, e.g. 0 0/10 * * * ?). A common cause is having a 5-field Linux cron like 0 2 * * * (missing the seconds field and ?).

    Fix (change the cron expression to a Quartz-compatible one)

    In ABP 9.3, some modules/workers can be scheduled via a CronExpression option. If you (or your config) set a 5-part cron for an audit logging cleanup worker, Quartz will crash at startup exactly like this.

    Update your related cron setting(s) to a Quartz cron format, for example:

    • Daily at 02:00:

      • Quartz: 0 0 2 * * ?
      • (Not 0 2 * * *)
    • Every 10 minutes:

      • Quartz: 0 0/10 * * * ?

    Where to apply it (typical ABP pattern in your HttpApiHostModule or the module where you configure audit logging options):

    public override void ConfigureServices(ServiceConfigurationContext context)
    {
        // If you have any audit log cleanup/background worker cron option configured,
        // make sure it is Quartz-compatible (6 parts).
        Configure<YourAuditLogCleanupWorkerOptions>(options =>
        {
            options.CronExpression = "0 0 2 * * ?"; // example
        });
    }
    

    If you don’t know which option you set: search your solution for CronExpression and for 5-part patterns like * * * * * in appsettings*.json and in Configure<...>(options => ...) blocks, and convert them to Quartz format.

    Quick isolation workaround (to confirm it’s a bad cron)

    Temporarily remove/clear the cron configuration (or comment it out). If the app starts, then re-add it with a 6-part Quartz cron.


    Sources

    • https://abp.io/docs/latest/framework/infrastructure/background-workers/quartz (validated)

    This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon.

  • User Avatar
    0
    sserestyen created

    Hi,

    I don't have any CronExpression in my project, apart from the ones which comes with the pro packages. As I don't have access to its source code I cannot verify those.

    What kind of workers and cron expressions do we have with the pro packages?

    Thanks.

  • User Avatar
    0
    sserestyen created

    [sserestyen] said: Hi,

    I don't have any CronExpression in my project, apart from the ones which comes with the pro packages.

    As I don't have access to its source code I cannot verify those.

    What kind of workers and cron expressions do we have with the pro packages?

    Thanks.

    Hi,

    I came across with related support tickets, and found that ExpiredAuditLogDeleterOptions can be configured. But, even though I change its default CronExpression ("0 23 * * *") to below, which should be valid for Quartz, I still get the same exception.

    Configure<ExpiredAuditLogDeleterOptions>(options => { options.CronExpression = "0 0 23 ? * * *"; });

    Could you advise what else needs to be change to work with Quartz?

    Thanks.

  • User Avatar
    0
    sserestyen created

    [sserestyen] said:

    [sserestyen] said:

    Hi,

    I don't have any CronExpression in my project, apart from the ones which comes with the pro packages.

    As I don't have access to its source code I cannot verify those.

    What kind of workers and cron expressions do we have with the pro packages?

    Thanks.

    Hi,

    I came across with related support tickets, and found that ExpiredAuditLogDeleterOptions can be configured.

    But, even though I change its default CronExpression ("0 23 * * *") to below, which should be valid for Quartz, I still get the same exception.

    Configure<ExpiredAuditLogDeleterOptions>(options =>

    {

    options.CronExpression = "0 0 23 ? * * *";
    

    });

    Could you advise what else needs to be change to work with Quartz?

    Thanks.

    Hi,

    Just an update, I was able to get around it. It turns out that I needed to apply both of below settings, as their default values were not compatible with Quartz.

    Configure<ExpiredAuditLogDeleterOptions>(options => { options.CronExpression = "0 0 23 ? * * *"; });

    Configure<AuditLogExcelFileOptions>(options => { options.ExcelFileCleanupOptions.CronExpression = "0 0 23 ? * * *"; });

    Based on the documentation those original values are not compatible with Quartz https://abp.io/docs/latest/modules/audit-logging-pro#expiredauditlogdeleteroptions

    Also, the below is not correct on the documentation options.ExcelFileCleanupOptions.CronExpression = "0 23 * * *"; // Quartz Cron expression is "0 23 * * * ?"

    The original cron is "0 23 * * *", which is "every day at 23:00", but Quartz Cron expression is "0 23 * * * ?" would mean every hour 23 mins. The correct configuration for Quartz Cron Expression is "0 0 23 ? * * *", which is identical with the original config.

    Could this be highlighted in the documentation of Quartz integration?

    Thanks.

Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.3.0-preview. Updated on March 02, 2026, 08:48
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.