简体   繁体   English

C# - Azure Durable Function - 重新启动编排

[英]C# - Azure Durable Function - Restart Orchestration

i'm working with durable functions.我正在使用持久功能。 I have already understood how Durable Functions work, so it has an Orchestration that controls the Flow (the order that activities work), that orchestration takes care of the Sequence of the Activities.我已经了解 Durable Functions 的工作原理,因此它有一个编排来控制流程(活动工作的顺序),该编排负责活动的顺序。

But currently i am having a question that i'm not finding the correct answer and maybe you can help me on that:但目前我有一个问题,我没有找到正确的答案,也许你可以帮助我:

Imagine that i have one orchestration, with 5 activities.想象一下,我有一个编排,有 5 个活动。 One of the activities do a Call to an API that will get a Document as an Array of bytes.其中一项活动调用 API,该 API 将获取作为字节数组的文档。

If one of the activities fail, the orchestration can throw an exception and i can detect that through the code.如果其中一项活动失败,编排可能会抛出异常,我可以通过代码检测到这一点。

Also i have some retry options that Retry the activities with an interval of 2 minutes.此外,我还有一些重试选项,可以以 2 分钟的间隔重试活动。 But... What if those retries doesn't success?但是...如果这些重试不成功怎么办?

As i was able to read, i can use "ContinueasNew" method in order to restart the orchestration, but there is a problem i think.由于我能够阅读,我可以使用“ContinueasNew”方法来重新启动编排,但我认为存在一个问题。 If i use this method in order to restart the orchestration 1 hour after, will it resume the activity where it was?如果我使用此方法在 1 小时后重新启动编排,它会恢复原来的活动吗?

I mean, if the first activity is done and when i restart the orchestration due to failure of one of the activities, will it resume on the 2nd activity as it was before?我的意思是,如果第一个活动完成并且当我由于其中一个活动失败而重新启动编排时,它会像以前一样在第二个活动中恢复吗?

Thank you for your time guys.谢谢你们的时间。

If you restart the orchestration, it doesn't have any state of the previous one.如果您重新启动编排,它不会有前一个的任何状态。 So the first activity will run again.所以第一个活动将再次运行。

If you don't want that to happen, you'll need to retry the second one until it succeeds.如果您不想发生这种情况,则需要重试第二个直到成功。 I would not recommend making that infinite though, an orchestration should always finish at some point.不过我不建议让它无限,编排应该总是在某个时候完成。 I'd just increase the retry count to a sufficiently high number so I can be confident that the processing will succeed in at least 99% of cases.我只是将重试次数增加到足够高的数字,这样我就可以确信处理会在至少 99% 的情况下成功。 (How likely is your activity to fail?) Then if it still fails, you could send a message to a queue and have it trigger some alert. (您的活动失败的可能性有多大?)然后如果它仍然失败,您可以向队列发送消息并让它触发一些警报。 You could then start that one from the beginning.然后你可以从头开始。 If something fails so many times that the retry amount is breached, there could be something wrong with the data itself and typically a manual intervention may be needed at that point.如果某件事失败了太多次以致重试量被破坏,则数据本身可能有问题,通常此时可能需要手动干预。

Another option could be to send the alert from within the orchestration if the retries fail, and then wait for an external event to come from an admin who approves or denies it to retry.另一种选择是,如果重试失败,则从编排内部发送警报,然后等待来自管理员批准或拒绝重试的外部事件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM