HangfireIO / HangfireIO/Hangfire
Zero latency processing does not work with multiple servers
- Dominant language
- C#
- Stars
- 10.1k
- Forks
- 1.8k
- Avg merge
- 1h 19m
- Merged PRs (30d)
- 1
Description
I noticed this recently that my jobs "latency" shown in the dashboard were higher than they use to be. I did a bit of debugging, and found that the "Zero latency processing" #520 feature doesn't appear to work anymore. Turns out it doesnt work when you have multiple HangfireServers running in the same app.
In my Startup.Configuration I call app.UseHangfireServer multiple times, to use different JobFilterCollection settings.. (Retry attempts etc)
If i remove them all but one, that one works fine with the "Zero latency processing" feature.
Those are my only differences, and if you are curious i made sure sure i was in the same app pool, and even double checked that the AutoResetEvent event was being fired still.
```csharp
var type = Type.GetType("Hangfire.SqlServer.SqlServerJobQueue, Hangfire.SqlServer");
System.Diagnostics.Trace.WriteLine("Found Hangfire Object");
System.Diagnostics.Trace.WriteLine(type != null? type.FullName : "(null)");
foreach (var p in type.GetFields(BindingFlags.Static | BindingFlags.NonPublic))
{
if (p.Name == "NewItemInQueueEvent")
{
System.Diagnostics.Trace.WriteLine("Found Hangfire Property");
resetEvent = (AutoResetEvent)p.GetValue(null);
}
}
while (true)
{
WaitHandle.WaitAny(new[] { resetEvent }, TimeSpan.FromMinutes(15));
System.Diagnostics.Trace.WriteLine("GOT EVENT!!@");
}
Contributor guide
Assessment
This issue has not been assessed yet.