Hangfire icon indicating copy to clipboard operation
Hangfire copied to clipboard

Execution function time is not match with the scheduled job time

Open umeshshende opened this issue 6 months ago • 1 comments

We have scheduled TriggerdNotitication() function at 12.10.10PM

Expected would be TriggerdNotitication() will be executed at 12.10.10PM But Actual TriggerdNotitication() is executed at 12.10.25PM

Version: 1.8.2 why this taken extra 15 sec sometimes its increase to 20sec sometimes its 14 sec it is not exact match with scheduled time

we have found this major issue as notification is delay instead within 1min it sent around 45sec or 40 sec

   TimeZoneInfo siteTZ = TimeZoneInfo.FindSystemTimeZoneById(SiteClient.SiteTimeZone);
    scheduleTime = TimeZoneInfo.ConvertTime(scheduleTime, TimeZoneInfo.Utc, siteTZ);
     scheduleTime = scheduleTime.AddHours(HelperMethods.GetHangireAWTimeZoneOffset());

     //Removing ACP-> PerItemItem from scheduled time
      scheduleTime = scheduleTime.AddMinutes(-Convert.ToDouble(perItemTiggerTime));

      BackgroundJob.Schedule(() => TriggerdNotitication(eventID, triggerTime), scheduleTime);

umeshshende avatar Feb 15 '24 13:02 umeshshende

@umeshshende The default value to check the Hangfire queue is set to 15 seconds. You can decrease this value if you want to reduce the delay

Liebeck avatar Feb 19 '24 15:02 Liebeck

Yes, Found the solution reduced the default queueing time 15 seconds to 5seconds

GlobalConfiguration.Configuration.UseSqlServerStorage(ConfigurationManager.ConnectionStrings["db_connection"].ConnectionString,
    new Hangfire.SqlServer.SqlServerStorageOptions
    { QueuePollInterval = TimeSpan.FromSeconds(5) });

app.UseHangfireServer(new BackgroundJobServerOptions()
{
    SchedulePollingInterval = TimeSpan.FromSeconds(5).
});

umeshshende avatar Feb 23 '24 09:02 umeshshende