abpframework/abp · error · AbpException

Background job execution is disabled. This method should not

Error message

Background job execution is disabled. This method should not be called! If you want to enable the background job execution, set AbpBackgroundJobOptions.IsJobExecutionEnabled to true! If you've intentionally disabled job execution and this seems to be a bug, please report it.

What it means

Thrown inside the TickerQ function delegate when a background job is dispatched for execution but AbpBackgroundJobOptions.IsJobExecutionEnabled is false. The TickerQ worker still receives the job (it's registered as a function) and, before executing, asserts that execution is enabled - if not, it throws AbpException. This protects against running job handlers in a host that intentionally disabled execution (e.g. a web node that only enqueues).

Source

Thrown at framework/src/Volo.Abp.BackgroundJobs.TickerQ/Volo/Abp/BackgroundJobs/TickerQ/AbpBackgroundJobsTickerQModule.cs:44

        var abpTickerQFunctionProvider = context.ServiceProvider.GetRequiredService<AbpTickerQFunctionProvider>();
        foreach (var jobConfiguration in abpBackgroundJobOptions.Value.GetJobs())
        {
            var genericMethod = GetTickerFunctionDelegateMethod.MakeGenericMethod(jobConfiguration.ArgsType);
            var tickerFunctionDelegate = (TickerFunctionDelegate)genericMethod.Invoke(null, [jobConfiguration.ArgsType])!;
            var config = abpBackgroundJobsTickerQOptions.Value.GetConfigurationOrNull(jobConfiguration.JobType);
            abpTickerQFunctionProvider.AddFunction(jobConfiguration.JobName, tickerFunctionDelegate, config?.Priority ?? TickerTaskPriority.Normal, config?.MaxConcurrency ?? 0);
            abpTickerQFunctionProvider.RequestTypes.TryAdd(jobConfiguration.JobName, (jobConfiguration.ArgsType.FullName, jobConfiguration.ArgsType)!);
        }
    }

    private static TickerFunctionDelegate GetTickerFunctionDelegate<TArgs>(Type argsType)
    {
        return async (cancellationToken, serviceProvider, context) =>
        {
            var options = serviceProvider.GetRequiredService<IOptions<AbpBackgroundJobOptions>>().Value;
            if (!options.IsJobExecutionEnabled)
            {
                throw new AbpException(
                    "Background job execution is disabled. " +
                    "This method should not be called! " +
                    "If you want to enable the background job execution, " +
                    $"set {nameof(AbpBackgroundJobOptions)}.{nameof(AbpBackgroundJobOptions.IsJobExecutionEnabled)} to true! " +
                    "If you've intentionally disabled job execution and this seems a bug, please report it."
                );
            }

            using (var scope = serviceProvider.CreateScope())
            {
                var jobExecuter = serviceProvider.GetRequiredService<IBackgroundJobExecuter>();
                var args = await TickerRequestProvider.GetRequestAsync<TArgs>(context, cancellationToken);
                var jobType = options.GetJob(typeof(TArgs)).JobType;
                var jobExecutionContext = new JobExecutionContext(scope.ServiceProvider, jobType, args!, cancellationToken: cancellationToken);
                await jobExecuter.ExecuteAsync(jobExecutionContext);
            }
        };
    }

View on GitHub (pinned to 7ed43b1931)

Solutions

  1. Enable execution in the worker host: configure AbpBackgroundJobOptions.IsJobExecutionEnabled = true.
  2. If this host should NOT run jobs, remove the TickerQ worker/job registration from it (or don't load the worker module here).
  3. Verify the option is configured in the correct host/project (PreConfigureServices/ConfigureServices of the executing app).
  4. Confirm you didn't disable execution globally while still loading the TickerQ module.

Example fix

// before: jobs dispatched but IsJobExecutionEnabled defaults/sets to false -> AbpException
// after
Configure<AbpBackgroundJobOptions>(options =>
{
    options.IsJobExecutionEnabled = true;
});
Defensive patterns

Strategy: validation

Validate before calling

var opts = serviceProvider.GetRequiredService<IOptions<AbpBackgroundJobOptions>>().Value;
if (!opts.IsJobExecutionEnabled)
{
    // do not dispatch jobs in this host, or enable the option
}

Type guard

null

Try / catch

try { /* job dispatch path */ }
catch (AbpException ex) when (ex.Message.Contains("Background job execution is disabled"))
{ /* enable IsJobExecutionEnabled or stop loading the worker module here */ }

Prevention

When it happens

Trigger: AbpBackgroundJobOptions.IsJobExecutionEnabled == false (the default in some host configurations or explicitly set) while a TickerQ worker function is invoked for a registered job type.

Common situations: Deploying a worker host that forgot to set IsJobExecutionEnabled = true; sharing the job module across a web API host (execution disabled) and a worker host; misconfigured environment where the worker module is loaded but the option isn't enabled; leftover registration after disabling execution.

Related errors


AI-assisted analysis of abpframework/abp@7ed43b1931 (2026-08-13). Data as JSON: /api/errors/e42d47f77bdcbd01. Report an issue: GitHub.