Hello,
I’m running a Hangfire 1.7.34 instance with UseSqlServerStorage and I have a synching job that can take more than 30 minutes to execute.
Here’s my configuration startup settings:
public static void ConfigureHangfireServices(this IServiceCollection services, IConfiguration configuration)
{
var appSettingsSection = configuration.GetSection("Settings");
var appSettings = appSettingsSection.Get<AppSettings>();
if (appSettings.EnableHangfireServices)
{
services.AddSingleton<IBackgroundJobManager, HangfireBackgroundJobManager>();
services.AddHangfire(options =>
{
options.SetDataCompatibilityLevel(CompatibilityLevel.Version_170);
options.UseSerilogLogProvider();
options.UseSimpleAssemblyNameTypeSerializer();
options.UseRecommendedSerializerSettings();
var connectionString = configuration.GetConnectionString("HangfireConnection");
if (string.IsNullOrEmpty(connectionString))
{
options.UseMemoryStorage();
}
else
{
options.UseSqlServerStorage(
configuration.GetConnectionString("HangfireConnection"),
new SqlServerStorageOptions
{
CommandBatchMaxTimeout = TimeSpan.FromMinutes(5),
SlidingInvisibilityTimeout = TimeSpan.FromMinutes(5),
QueuePollInterval = TimeSpan.Zero,
UseRecommendedIsolationLevel = true,
UsePageLocksOnDequeue = true,
DisableGlobalLocks = true,
});
}
});
//add the processing server as IHostedService
services.AddHangfireServer();
services.RegisterJobs();
}
services.AddScoped<IBackgroundJobClient, BackgroundJobClient>(x => new BackgroundJobClient(
new SqlServerStorage(configuration.GetConnectionString("HangfireConnection"))));
}
I’ve read that starting from Hangfire 1.5 the InvisibilityTimeout is deprecated.
Any suggestion?