[英]Iterative activity in Cadence / Temporal workflow
This can be considered a follow-up question to Invoking the same activity inside a loop in cadence workflow : How does the workflow recover in case of activity iteration?这可以被认为是Invoking the same activity inside a loop in cadence workflow的后续问题:在活动迭代的情况下工作流如何恢复? Will is continue invoking the i-th activity (skipping the ones that were already invoked) or start again from 0?将继续调用第 i 个活动(跳过已调用的活动)还是从 0 重新开始? If so, how can the workflow be written so that activities that were invoked (0-'k') are skipped?如果是这样,如何编写工作流以便跳过调用的活动(0-'k')?
Each activity invocation has its own retry policy, so if activity i fails, only activity i will be retried.每个活动调用都有自己的重试策略,因此如果活动 i 失败,则只有活动 i 会被重试。
My understanding is those iterations are replayed when the history is retrieved in the rescuing worker.我的理解是,当在救援人员中检索历史时,这些迭代会被重播。
So iteration 1 had result 'x', iteration 2 had 'y' until it reaches the last activity that it hadn't recorded a result for, and then starts actually invoking the activities.所以迭代 1 的结果为“x”,迭代 2 的结果为“y”,直到它到达最后一个没有记录结果的活动,然后开始实际调用活动。
In this way, you can be sure the state of the workflow, and its potential variables, is exactly how it was when it terminated.通过这种方式,您可以确定工作流的 state 及其潜在变量与终止时的状态完全相同。
So they aren't exactly 'skipped' but they also don't re-execute.所以它们并没有完全“跳过”,但它们也不会重新执行。
If you don't want to replay hundreds of no-op iterations after a failure, you could consider using "continueAsNew" instead of a loop.如果您不想在失败后重播数百次无操作迭代,您可以考虑使用“continueAsNew”而不是循环。 This ensures the new workflow doesn't accrue the history of the other failed iterations.这可确保新工作流不会累积其他失败迭代的历史记录。
First of all, it's important to understand the difference between workflow worker vs activity worker.首先,了解工作流工作者与活动工作者之间的区别很重要。
Coming back to your question: When your "workflow" worker crashes, restarts, lost or somehow a worker received a decision task that it doesn't know about its workflow;回到您的问题:当您的“工作流程”工作人员崩溃、重新启动、丢失或以某种方式接收到不了解其工作流程的决策任务时; it will then request the history of that workflow from Cadence servers.然后它将从 Cadence 服务器请求该工作流的历史记录。 It will replay the workflow until is consumes the whole history it receives then will schedule the next activity based on current local variables.它将重放工作流,直到消耗它收到的整个历史记录,然后将根据当前的局部变量安排下一个活动。
So it will continue from the same loop iteration with the same local variables and parameters to the activity.因此,它将使用相同的局部变量和参数从同一个循环迭代继续到活动。
Hope this answers your question希望这能回答你的问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.