Timeout in an Activity Function of Azure Durable Functions

ぃ、小莉子 提交于 2020-01-06 18:36:29

问题


In my activity function I am doing this

do {
     await timeout(500);
} while (await getStatus() === false);

where,

function timeout(ms) {
      return new Promise(resolve => setTimeout(resolve, ms));
}

getStatus() is a function that does a get request to see if process in other service is complete or not and returns true or false based on this.

I need my activity function to wait before the process in other service is complete. But activity function execution by default is limited to 5 minutes. my getStatus() can take more than 2-3 hours or more based on different scenarios to return true.

What can I do here? Any advice?


回答1:


You have a couple of options:

Option A: Use Monitor pattern + Rewind

Could you split out the getStatus code to another Activity Function instead? If yes, then assume the following:

  1. ActivityFunction_A - contains code before the do-while loop that is polling with getStatus()

  2. ActivityFunction_B - contains the code that polls for getStatus with maximum execution time of 10 minutes.

  3. ActivityFunction_C - contains code after the getStatus returns TRUE

You can now orchestrate the workflow sequence

ActivityFunction_A => ActivityFunction_B => ActivityFunction_C

using the Monitor pattern.

Since any one of the Activity Functions could fail or timeout and there are potential side-effects of executing each activity function, you should also use the Rewind feature (currently in preview) to rewind and replay only starting from the first failed Activity Function in the sequence.

Option B: Use App Service Plan

If your workflow does not really need to scale out to a lot of instances dynamically, you can migrate your Functions to an App Service Plan with AlwaysOn turned on.



来源:https://stackoverflow.com/questions/53864209/timeout-in-an-activity-function-of-azure-durable-functions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!