I use Recurring Job to call my function Test() with Cron.Daily() .
I does not need to fetch database every 15 second , my function executed every day only once .
how to stop hangfire to fetch database every 15 second ? or update interval.
this is configuration I am using it.
services.AddHangfire(config =>
config.SetDataCompatibilityLevel(CompatibilityLevel.Version_170)
.UseSimpleAssemblyNameTypeSerializer()
.UseDefaultTypeSerializer()
.UseSqlServerStorage(configuration.GetConnectionString(“BackOffice”))
);
var sqlStorage = new SqlServerStorage(configuration.GetConnectionString(“BackOffice”));
JobStorage.Current = sqlStorage;
this is done with the command where you start the job … you can edit when and how often with a cron-command (time)… so, post the row where you start the function so that we can see how you are starting the recurrent job.
15s is the default polling interval for SqlServer. If the polling interval isn’t changing when you use SqlServerStorageOptions you’re probably setting it too late. You need to set it in the call to AddHangfire(), not later.
services.AddHangfire(config =>
config
.SetDataCompatibilityLevel(CompatibilityLevel.Version_170)
.UseSimpleAssemblyNameTypeSerializer()
.UseDefaultTypeSerializer()
.UseSqlServerStorage(configuration.GetConnectionString(“BackOffice”),
// Only poll for hangfire jobs once per hour
new SqlServerStorageOptions{
QueuePollInterval = new TimeSpan(0, 1, 0, 0, 0))
})
);
// These lines you had aren't needed:
// var sqlStorage = new SqlServerStorage(configuration.GetConnectionString(“BackOffice”));
// JobStorage.Current = sqlStorage;
// You don't need to pass sqlServerStorage here; you've already set it in AddHangfire()
services.AddHangfireServer();
// This line is also not needed:
// GlobalConfiguration .Configuration.UseSqlServerStorage(...
services.AddHttpClient();