delaydelayed-jobhangfirehangfire-sql

Hangfire - Execution function time is not match with the scheduled job time


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);

Solution

  • 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).
    });