Description
Description
I used a background job and added a queue attribute. I wrote a custom jobfilter attribute
public class DisableMultipleQueuedItemsAttribute : JobFilterAttribute, IClientFilter, IServerFilter, IElectStateFilter {}
to calculate a fingerprint to ensure a backgroundjob is not called multiple times.
In the Attribute I can read the job parameter and queue is null there.
Steps to Reproduce
------------------------- hangfire config start----------------------
var jobStorage = new SqlServerStorage(_configuration.GetConnectionString("MyConnectionString"));
// Add Hangfire services
services.AddHangfire(configuration =>
{
configuration.UseStorage(jobStorage);
});
services.AddHangfireServer((_, backgroundJobServerOptions) =>
{
backgroundJobServerOptions.Queues = new[] { "WinService", "default") };
backgroundJobServerOptions.WorkerCount = 5;
});
------------------------- hangfire config end----------------------
------------------------- Backgroundjob start----------------------
[Queue("WinService")]
[DisableMultipleQueuedItems]
public async Task SynchronizeAsync(int param1, int param2) {}
------------------------- Backgroundjob end----------------------
------------- calling the job --------------------
BackgroundJob.Enqueue(x => x.SynchronizeAsync(param1, param2);
Observed Behavior
when I set the debugger in my custom attribute the jobs queue is null
Expected Behavior
Queue is set to "WinService" but is null. The correct hangfire process is executing the job
------------------------- hangfire config start----------------------
var jobStorage = new SqlServerStorage(_configuration.GetConnectionString("MyConnectionString"));
// Add Hangfire services
services.AddHangfire(configuration =>
{
configuration.UseStorage(jobStorage);
});
services.AddHangfireServer((_, backgroundJobServerOptions) =>
{
backgroundJobServerOptions.Queues = new[] { "webui") };
backgroundJobServerOptions.WorkerCount = 5;
});
------------------------- hangfire config end----------------------
Additional Information
My setup was:
.NET 6
Hangfire 1.8.17