0

我们正在使用 Azure Web Jobs SDK 创建一个包含一个TimerTrigger侦听器的 Web 作业。侦听器配置为每 30 秒运行一次,超时设置为 5 秒。

[Singleton]
[Timeout("00:00:05", ThrowOnTimeout = true, TimeoutWhileDebugging = true)]
public async Task RunApplication([TimerTrigger("*/30 * * * * *")] TimerInfo timerInfo, ILogger logger)
{
    await application.RunAsync();
}

不幸的是,一旦Microsoft.Azure.WebJobs.Host.FunctionTimeoutException: Timeout value of 00:00:05 was exceeded by function: Functions.RunApplication抛出,WebJobHost 与现有的 Timer-triggered Listener 一起被关闭。以下是相关日志:

[18:41:36 DBG] Hosting stopping
[18:41:36 INF] Stopping JobHost
[18:41:36 DBG] Hosting stopping
[18:41:36 INF] Stopping JobHost
[18:41:36 INF] Stopping the listener 'Microsoft.Azure.WebJobs.Host.Listeners.SingletonListener' for function 'RunApplication'
[18:41:37 DBG] Singleton lock released (7b5ea8830199bb05df579f591e3f6e59/Integration.DynataRex.LoadSurveys.Functions.RunApplication.Listener)
[18:41:37 INF] Stopped the listener 'Microsoft.Azure.WebJobs.Host.Listeners.SingletonListener' for function 'RunApplication'
[18:41:37 INF] Job host stopped
[18:41:37 DBG] Hosting stopped
[18:41:37 DBG] Hosting stopped

Web 作业在超时时的期望行为是,而不是关闭主机,只需重新调度侦听器并在下一个时间间隔重新运行它。我们应该怎么做?

4

0 回答 0