[LogEverything]
public class LongJob
{
public void Execute()
{
Console.WriteLine("LongJob Started at {0}", DateTime.UtcNow.ToLongDateString());
Task.Delay(6 * 60 * 1000).GetAwaiter().GetResult();
Console.WriteLine("LongJob Finished at {0}", DateTime.UtcNow.ToLongDateString());
}
}
When the custom job filter attribute is not working when it is annotated at the class or method. It works only when registered as Global job filter.
Replication Steps:
Configure jobs using Configure jobs
builder.Services.AddHangfire(configuration => configuration .SetDataCompatibilityLevel(CompatibilityLevel.Version_180) .UseSimpleAssemblyNameTypeSerializer() .UseRecommendedSerializerSettings() .UseFilter(new AutomaticRetryAttribute { Attempts = 0 }) .UseInMemoryStorage(new InMemoryStorageOptions { IdType = InMemoryStorageIdType.Long, StringComparer = StringComparer.InvariantCultureIgnoreCase // Default value, case-sensitive. }));
builder.Services.AddHangfireServer(opts => { opts.WorkerCount = Environment.ProcessorCount * 5; opts.ServerName = "Test Scheduler"; opts.Queues = ["scheduler"]; opts.StopTimeout = TimeSpan.FromMinutes(3); opts.ShutdownTimeout = TimeSpan.FromMinutes(3); });