You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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"));
------------------------- 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"));
Please confirm that the attributes applied to the SynchornizeAsync method of the Scheduler class, because otherwise, for example when background job is created on some abstract class, base class or an interface, Hangfire will be unable to see the attributes.
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
The text was updated successfully, but these errors were encountered: