如何解决Azure WebJob执行该功能的次数比应执行的次数多
我创建了一个连续的WebJob,该WebJob应该每5分钟执行一次我的公共功能。
它已经工作了好几天,但是最近发现它在较短的时间内被两次调用。在开发AppService中,我可以看到它首先被调用,然后分别在1分钟和20秒后被调用两次。在生产中,差异甚至更短(20秒)。
Program.cs:
public static void Main()
{
var config = new JobHostConfiguration();
if (config.IsDevelopment)
{
config.UseDevelopmentSettings();
}
config.UseTimers();
var host = new JobHost(config);
// The following code ensures that the WebJob will be running continuously
host.RunAndBlock();
}
Functions.cs:
public static async Task ProcessDocumentsRoundAboutAsync([TimerTrigger("00:05:00",RunOnStartup = false,UseMonitor = true)] TimerInfo timer)
{
var handler = new ProcessCandidatesHandler();
await handler.ExecuteAsync();
}
WebJob输出详细信息表明应该每5分钟调用一次:
[09/09/2020 07:16:54> fc5cb9:INFO]执行中 'Functions.ProcessDocumentsRoundAboutAsync'(原因='计时器在 2020-09-09T 09:16:54 .5243173 + 02:00', Id = 9c64dfc4-e7b3-4857-a9bc-df40cc7d58c9)
[09/09/2020 07:16:56> fc5cb9:INFO]已执行 'Functions.ProcessDocumentsRoundAboutAsync'(成功, Id = 9c64dfc4-e7b3-4857-a9bc-df40cc7d58c9)
[09/09/2020 07:22:06> fc5cb9:INFO]执行中 'Functions.ProcessDocumentsRoundAboutAsync'(原因='计时器在 2020-09-09T09:21:54.5364353 + 02:00', id = e06eb211-2a6c-49a0-a9ce-1aee003dc545)
[09/09/2020 07:22:07> fc5cb9:INFO]已执行 'Functions.ProcessDocumentsRoundAboutAsync'(成功, id = e06eb211-2a6c-49a0-a9ce-1aee003dc545)
功能调用日志:
Functions.ProcessDocumentsRoundAboutAsync(09/09/2020 09:21:5 ...) Functions.ProcessDocumentsRoundAboutAsync(09/09/2020 09:20:3 ...) Functions.ProcessDocumentsRoundAboutAsync(09/09/2020 09:16:5 ...)
我找到了this solution,但是它不符合我的需求,因为我想连续运行它(允许我对其进行调试,不需要“热身”),当然我想知道发生这种情况的真正原因。
我不知道为什么到现在为止一切正常,为什么会这样。有任何想法吗?谢谢。
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。