我们已将 TriggerdNotitication() 函数安排在 12.10.10PM
预计将在12.10.10PM执行TriggerdNotitication() 但是实际 TriggerdNotitication() 是在 12.10.25PM
执行的版本:1.8.2
为什么这需要额外的 15 秒,有时会增加到 20 秒,有时会增加到 14 秒,这与预定时间不完全匹配
我们发现了这个主要问题,因为通知延迟了,而不是在 1 分钟内发送,大约 45 秒或 40 秒
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);
Hangfire 中的计划设置不是用于作业执行,而是用于作业排队。 这意味着作业将被放入队列中,并在hangfire 服务器上的工作人员之一可用时执行。
如果出现以下情况,可能会延迟:
找到解决方案将默认排队时间从15秒减少到5秒
GlobalConfiguration.Configuration.UseSqlServerStorage(ConfigurationManager.ConnectionStrings["db_connection"].ConnectionString,
new Hangfire.SqlServer.SqlServerStorageOptions
{ QueuePollInterval = TimeSpan.FromSeconds(5) });
app.UseHangfireServer(new BackgroundJobServerOptions()
{
SchedulePollingInterval = TimeSpan.FromSeconds(5).
});