I am trying to use Hangfire as a Background Job manager with mysql:8.0 as persistence storage. I Use the nuget package "Hangfire.MySqlStorage" Version="2.0.3" to integrate with MySQL. I have the following configuration the the BlazorModule
private static void ConfigureHangfire(ServiceConfigurationContext context, IConfiguration configuration)
{
context.Services.AddHangfire(config =>
{
config.UseStorage(
new MySqlStorage(
configuration.GetConnectionString("Default") ?? throw new InvalidOperationException("The [ConnectionString:Hangfire] is not configured."),
new MySqlStorageOptions()
)
);
});
context.Services.AddHangfireServer(o =>
{
//o.Queues = new[] { "default", "emails" }; // optional
o.ServerName = "vfsdbuploader-hf";
});
When I run the Process the tables are successfully created but the Process is terminated with the following Error
[13:18:26 FTL] Host terminated unexpectedly!
Volo.Abp.AbpInitializationException: An error occurred during the initialize Volo.Abp.Modularity.OnApplicationInitializationModuleLifecycleContributor phase of the module Volo.Abp.Identity.AbpIdentityProDomainModule, Volo.Abp.Identity.Pro.Domain, Version=9.3.5.0, Culture=neutral, PublicKeyToken=null: Current storage doesn't support specifying queues directly for a specific job. Please use the QueueAttribute instead.. See the inner exception for details.
---> System.NotSupportedException: Current storage doesn't support specifying queues directly for a specific job. Please use the QueueAttribute instead.
at Hangfire.RecurringJobManager.AddOrUpdate(String recurringJobId, Job job, String cronExpression, RecurringJobOptions options) in C:\projects\hangfire-525\src\Hangfire.Core\RecurringJobManager.cs:line 108
at Hangfire.RecurringJob.AddOrUpdate(String recurringJobId, String queue, Expression`1 methodCall, String cronExpression, RecurringJobOptions options) in C:\projects\hangfire-525\src\Hangfire.Core\RecurringJob.cs:line 568
at Volo.Abp.BackgroundWorkers.Hangfire.HangfireBackgroundWorkerManager.AddAsync(IBackgroundWorker worker, CancellationToken cancellationToken)
at Volo.Abp.Identity.AbpIdentityProDomainModule.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)
at VfsDbUploader.Blazor.Program.Main(String[] args) in C:\Users\gpanagakis\Desktop\wc\vfs-db-uploader\src\VfsDbUploader.Blazor\Program.cs:line 66
I have no application specific Job or workers defined the problem is caused by internal ABP worker that are being initialized. When I run the same App using Redis as a Hangfire backend everything is initialized correctly and the following workers are started
[19:45:40 DBG] Started background worker: Volo.Abp.BackgroundJobs.BackgroundJobWorker
[19:45:40 DBG] Started background worker: Volo.Abp.Identity.Session.IdentitySessionCleanupBackgroundWorker
[19:45:40 DBG] Started background worker: Volo.Abp.OpenIddict.Tokens.TokenCleanupBackgroundWorker
[19:45:41 DBG] Started background worker: Volo.Abp.AuditLogging.ExpiredAuditLogDeleterWorker
[19:45:41 DBG] Started background worker: Volo.Abp.AuditLogging.ExcelFileDownload.ExcelFileCleanupWorker
I tried to use the suggestion "Please use the QueueAttribute " but the problem arises from ABP internal workers that are not under my control What is your suggestion to resolve the issue?
Thank you in advance
4 Answer(s)
-
0
- Solution
Root cause
- Hangfire.MySqlStorage (v2.0.3) does not support passing the queue name to RecurringJob.AddOrUpdate via options for a specific job. ABP’s HangfireBackgroundWorkerManager uses Hangfire’s RecurringJob.AddOrUpdate with a queue parameter for some internal background workers (e.g., token/audit cleanup), which triggers “Current storage doesn't support specifying queues directly for a specific job. Please use the QueueAttribute instead.” MySQL storage provider throws NotSupportedException in this case.
- With Redis storage, specifying queues per job is supported; therefore it works.
What you can do
Preferred: Switch to an implementation that supports per-job queues
- Use a Hangfire storage provider that supports per-job queue selection (e.g., Redis, SQL Server). Your existing Redis setup already works.
Or, keep MySQL but disable ABP’s Hangfire background workers and use a different background worker implementation in ABP
- Replace ABP’s Hangfire-based background workers with Quartz for the “background workers” part, while still using Hangfire for BackgroundJobs if you need it. ABP allows mixing implementations:
- Install and depend on AbpBackgroundWorkersQuartzModule in your Domain layer to run ABP’s internal workers (cleanup, etc.) with Quartz (which doesn’t use Hangfire queues).
- Keep Hangfire only for BackgroundJobs (IBackgroundJobManager) if you still want Hangfire for enqueueing fire-and-forget jobs. If using MySQL storage for Hangfire, avoid per-job queue customization from your own jobs (or mark job classes with [Queue] attribute only if your storage supports it).
Example module setup:
- Replace ABP’s Hangfire-based background workers with Quartz for the “background workers” part, while still using Hangfire for BackgroundJobs if you need it. ABP allows mixing implementations:
[DependsOn( typeof(AbpBackgroundWorkersQuartzModule), // run ABP workers via Quartz typeof(AbpBackgroundJobsModule) // keep generic jobs; add Hangfire only if you need it // typeof(AbpBackgroundJobsHangfireModule) // include only if you will use Hangfire for IBackgroundJobManager )] public class MyProjectDomainModule : AbpModule { public override void PreConfigureServices(ServiceConfigurationContext context) { // Configure Quartz persistence (e.g., MySQL/PostgreSQL/SQL Server) PreConfigure<AbpQuartzOptions>(options => { options.Configurator = cfg => { cfg.UsePersistentStore(store => { store.UseProperties = true; store.UseJsonSerializer(); store.UseMySql("Your MySQL connection string"); // or other provider }); }; }); } }- In your web host, remove AddHangfireServer if you don’t need Hangfire workers at all, or keep it only for background jobs that don’t specify per-job queue options in a way MySQL storage rejects. - ABP’s internal workers (Identity session cleanup, token cleanup, audit log cleanup, etc.) will run under Quartz and won’t call Hangfire. That sidesteps the Hangfire/MySQL queue limitation.- If you must stay with Hangfire + MySQL for everything
- This combination is currently incompatible with ABP’s internal workers that specify queues per job. There’s no knob in ABP to stop it from passing the queue to RecurringJob.AddOrUpdate for those workers.
- Unless Hangfire.MySqlStorage adds support for per-job queue selection via recurring jobs, the only options are:
- Contribute a PR to Hangfire.MySqlStorage to support queues passed during RecurringJob.AddOrUpdate, or
- Fork ABP’s HangfireBackgroundWorkerManager to remove the queue parameter (not recommended; you’ll diverge from ABP).
- Minimal change recipe (keeps MySQL, removes the crash)
- Keep your Hangfire.MySqlStorage registration if you still want Hangfire to store BackgroundJobs.
- Add Quartz for background workers and disable ABP’s Hangfire workers by not depending on AbpBackgroundWorkersHangfireModule anywhere. Ensure your Solution depends on AbpBackgroundWorkersQuartzModule.
- Result: ABP internal workers run on Quartz; Hangfire remains usable for IBackgroundJobManager. No crash.
- Sources
- HangfireBackgroundWorkerManager (ABP source – shows how ABP registers recurring jobs and passes queue):
- https://github.com/abpframework/abp/blob/dev/framework/src/Volo.Abp.BackgroundWorkers.Hangfire/Volo/Abp/BackgroundWorkers/Hangfire/HangfireBackgroundWorkerManager.cs
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.
-
0
hi
What is your abp package version?
-
0
https://github.com/arnoldasgudas/Hangfire.MySqlStorage doesn't support the latest Hangfire >=1.8.0
see https://github.com/HangfireIO/Hangfire/issues/2319#issuecomment-1933619870
-
0
You can also try to override the
HangfireBackgroundWorkerManagerhttps://github.com/abpframework/abp/blob/dev/framework/src/Volo.Abp.BackgroundWorkers.Hangfire/Volo/Abp/BackgroundWorkers/Hangfire/HangfireBackgroundWorkerManager.cs#L18
Just remove the
QueuefromRecurringJob.AddOrUpdateThanks.