Hangfire DisableConcurrentExecution: What happens when the timeout expires?

I tested that recently. That job instance was recorded as failed in the dashboard and listed the exception which indicated that the timeout had expired while waiting for an exclusive lock. You’ll see the following exception: Hangfire.Storage.DistributedLockTimeoutException: Timeout expired. The timeout elapsed prior to obtaining a distributed lock on the ‘xxx’ resource. at Hangfire.SqlServer.SqlServerDistributedLock.Acquire(IDbConnection connection, … Read more

How to invoke async methods in Hangfire?

Based on one of the examples on the repository on github Just remove the Wait blocking call _backgroungJobClient.Enqueue(() => _downloader.DownloadAsync(files)); The method knows now how to handle Func that returns Task Hangfire 1.6.0 – Blog The enqueueing logic is the same for sync and async methods. In early betas there was a warning CS4014, but … Read more

Hangfire recurring tasks under minute

Not sure when this became supported but tried this in ASP.NET Core 2.0 with Hangfire 1.7.0. The following code schedules a job every 20 seconds: RecurringJob.AddOrUpdate<SomeJob>( x => x.DoWork(), “*/20 * * * * *”); If I am not mistaken 6 tokens (as opposed to standard 5 tokens) is supported due to Hangfire use of … Read more

Hangfire dependency injection with .NET Core

See full example on GitHub https://github.com/gonzigonz/HangfireCore-Example. Live site at http://hangfirecore.azurewebsites.net/ Make sure you have the Core version of Hangfire: dotnet add package Hangfire.AspNetCore Configure your IoC by defining a JobActivator. Below is the config for use with the default asp.net core container service: public class HangfireActivator : Hangfire.JobActivator { private readonly IServiceProvider _serviceProvider; public HangfireActivator(IServiceProvider … Read more

tech