Hangfire.Storage.SQLite
Hangfire.Storage.SQLite copied to clipboard
NotSupportedException: Current storage doesn't support specifying queues directly for a specific job
NotSupportedException: Current storage doesn't support specifying queues directly for a specific job
Hangfire.BackgroundJobClientException: Background job creation failed. See 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.Client.CoreBackgroundJobFactory.Create(CreateContext context)
at Hangfire.Client.BackgroundJobFactory.<>c__DisplayClass12_0.<CreateWithFilters>b__0()
at Hangfire.Client.BackgroundJobFactory.InvokeClientFilter(IClientFilter filter, CreatingContext preContext, Func`1 continuation)
at Hangfire.Client.BackgroundJobFactory.<>c__DisplayClass12_1.<CreateWithFilters>b__2()
at Hangfire.Client.BackgroundJobFactory.CreateWithFilters(CreateContext context, IEnumerable`1 filters)
at Hangfire.Client.BackgroundJobFactory.Create(CreateContext context)
at Hangfire.BackgroundJobClient.Create(Job job, IState state, IDictionary`2 parameters)
--- End of inner exception stack trace ---
at Hangfire.BackgroundJobClient.Create(Job job, IState state, IDictionary`2 parameters)
at Hangfire.BackgroundJobClient.Create(Job job, IState state)
at Hangfire.BackgroundJobClientExtensions.Create(IBackgroundJobClient client, String queue, Expression`1 methodCall, IState state)
at Hangfire.BackgroundJobClientExtensions.Enqueue(IBackgroundJobClient client, String queue, Expression`1 methodCall)
at HangfirePlugin.Controllers.TestController.Test1()
at lambda_method15(Closure , Object )
[ApiController]
public class TestController : ControllerBase
{
private readonly IBackgroundJobClient _backgroundJobClient;
public TestController(IBackgroundJobClient backgroundJobClient)
{
_backgroundJobClient = backgroundJobClient;
}
[HttpGet]
public async Task<ActionResult> Test1()
{
{
_backgroundJobClient.Enqueue(queue: "test_queue_1", methodCall: () => Test1_NonAction(5));
_backgroundJobClient.Enqueue(queue: "test_queue_1", methodCall: () => Test1_NonAction(1));
_backgroundJobClient.Enqueue(queue: "test_queue_1", methodCall: () => Test1_NonAction(3));
}
return Content("Ok");
}
[NonAction]
public async Task Test1_NonAction(int num)
{
Thread.Sleep(1000 * num);
Console.WriteLine("--------------------------------------------------------------------------------");
Console.WriteLine($"{num} from Hangfire! - {DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
Console.WriteLine("--------------------------------------------------------------------------------");
}
}
<PackageReference Include="Hangfire.Core" Version="1.8.9" />
<PackageReference Include="Hangfire.AspNetCore" Version="1.8.9" />
<!-- https://github.com/raisedapp/Hangfire.Storage.SQLite -->
<PackageReference Include="Hangfire.Storage.SQLite" Version="0.4.0" />
Thanks
The code for that feature is already implemented.
I just saw that we don't advertise the supported features in the Storage. Which leads to the observed exception.
Without much (if any) code we can add support for the following features
- JobStorageFeatures.ExtendedApi
- JobStorageFeatures.JobQueueProperty
- JobStorageFeatures.Connection.GetUtcDateTime
- JobStorageFeatures.Connection.BatchedGetFirstByLowest
- JobStorageFeatures.Connection.GetSetContains
- JobStorageFeatures.Connection.LimitedGetSetCount
- "BatchedGetFirstByLowestScoreFromSet"
for this the Storage needs to override HasFeatures as seen here https://github.com/HangfireIO/Hangfire.InMemory/blob/935aaadccaa98d1ec64562be64ce9d75f848201a/src/Hangfire.InMemory/InMemoryStorage.cs