{"record":{"id":"58b1e98e5cbc25a2","repo":"HangfireIO/Hangfire","slug":"current-storage-doesn-t-support-specifying-queues-58b1e9","errorCode":null,"errorMessage":"Current storage doesn't support specifying queues directly for a specific job. Please use the QueueAttribute instead.","messagePattern":"Current storage doesn't support specifying queues directly for a specific job\\. Please use the QueueAttribute instead\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/Hangfire.Core/States/EnqueuedState.cs","lineNumber":278,"sourceCode":"            }\n\n            return true;\n        }\n\n        internal sealed class Handler : IStateHandler\n        {\n            public void Apply(ApplyStateContext context, IWriteOnlyTransaction transaction)\n            {\n                var enqueuedState = context.NewState as EnqueuedState;\n                if (enqueuedState == null)\n                {\n                    throw new InvalidOperationException(\n                        $\"`{typeof (Handler).FullName}` state handler can be registered only for the Enqueued state.\");\n                }\n\n                if (context.BackgroundJob.Job?.Queue != null && !context.Storage.HasFeature(JobStorageFeatures.JobQueueProperty))\n                {\n                    throw new NotSupportedException(\"Current storage doesn't support specifying queues directly for a specific job. Please use the QueueAttribute instead.\");\n                }\n\n                transaction.AddToQueue(\n                    context.BackgroundJob.Job?.Queue == null || !DefaultQueue.Equals(enqueuedState.Queue, StringComparison.OrdinalIgnoreCase)\n                        ? enqueuedState.Queue\n                        : context.BackgroundJob.Job.Queue,\n                    context.BackgroundJob.Id);\n            }\n\n            public void Unapply(ApplyStateContext context, IWriteOnlyTransaction transaction)\n            {\n            }\n\n            // ReSharper disable once MemberHidesStaticFromOuterClass\n            public string StateName => EnqueuedState.StateName;\n        }\n    }\n}","sourceCodeStart":260,"sourceCodeEnd":296,"githubUrl":"https://github.com/HangfireIO/Hangfire/blob/c236dd0f930f831ec151e436e138ddc429a02a72/src/Hangfire.Core/States/EnqueuedState.cs#L260-L296","documentation":"Thrown by the EnqueuedState.Handler.Apply when the background job's method carries a Queue (e.g. via [Queue(\"...\")] on the method or Job.Queue set) but the configured JobStorage does not advertise the JobQueueFeatures.JobQueueProperty capability. Hangfire only honors a per-job queue override on storages that explicitly support it; otherwise you must select the queue at the server level.","triggerScenarios":"Decorating a job method with [Queue(\"custom\")] or constructing a Job with a non-null Queue while using a storage whose JobStorageFeatures does not include JobQueueProperty (e.g. some custom or in-memory storage implementations).","commonSituations":"Switching from SqlServer/Redis storage (which support the feature) to a minimal custom storage; writing a test storage that did not opt into the JobQueueProperty feature flag; applying [Queue] attribute assuming all storages honor it.","solutions":["Remove the [Queue] attribute from the job method and route the job through a server that listens on the desired queue via BackgroundJobServerOptions.Queues.","If per-job queuing is required, switch to or extend a storage that sets JobStorageFeatures.JobQueueProperty in its features.","Check storage.Features at startup and log a warning when the app uses [Queue] but the feature is absent."],"exampleFix":"// before\n[Queue(\"critical\")]\npublic void SendEmail(string to) { ... }\n\n// after (route via server queues instead)\npublic void SendEmail(string to) { ... }\n// server: new BackgroundJobServer(new BackgroundJobServerOptions { Queues = new[] { \"critical\", \"default\" } });","handlingStrategy":"validation","validationCode":"static bool StorageSupportsJobQueue(JobStorage storage)\n    => storage.HasFeature(JobStorageFeatures.JobQueueProperty);\n\n// at startup:\nif (JobStorage.Current != null && !StorageSupportsJobQueue(JobStorage.Current))\n    Console.WriteLine(\"Warning: current storage does not support per-job [Queue]; remove the attribute.\");","typeGuard":null,"tryCatchPattern":"try\n{\n    client.Create(job, initialState);\n}\ncatch (NotSupportedException ex) when (ex.Message.Contains(\"QueueAttribute\"))\n{\n    // fall back: enqueue without per-job queue, let server queues handle routing\n    client.Create(job with { Queue = null }, initialState);\n}","preventionTips":["Decide queue selection strategy up front: per-job [Queue] requires a capable storage.","Write an integration test that asserts your storage advertises JobQueueProperty when you rely on [Queue].","Document, per environment, whether [Queue] is allowed."],"tags":["storage-feature","queue","not-supported"],"backgroundTag":null,"analyzedSha":"c236dd0f930f831ec151e436e138ddc429a02a72","analyzedAt":"2026-08-13T20:27:11.027Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}