Child 工作流程会在 parent 完成后继续 运行 吗? (ChildPolicy.ABANDON)

Will Child workflow continue to run after parent is finished? (ChildPolicy.ABANDON)

我想从一个工作流 (parent) 触发 child 个工作流。基本上这会在决策程序

的循环中发生
@Workflow
@WorkflowRegistrationOptions(defaultExecutionStartToCloseTimeoutSeconds = 240,
              defaultTaskStartToCloseTimeoutSeconds = 60)
public interface W1{
    @Execute(version = "1.0")
    void fn();
}

public class W1Impl implements W1{
    ChildClientFactory factory = new ChildClientFactoryImpl();

    @Override
    public void fn() {
       int i;
      /*
          I'll call activity1 that returns me a list(size = n)
          I trigger n child worflows(Each takes the content in the list and operates)
      */
       for(i = 0; i < n; i++) {
          ChildClient childWorkflowClient = factory.getClient();
          childWorkflowClient.someMethod(params);//TRIGGERING CHILD WORKFLOW
      }
    }
}

parent 工作流程无需等待 child 工作流程完成。即)child 工作流将根据对它们的输入进行一些处理,并将结果放入持久性存储中。 所以我没有从 child 工作流程中 returning promise

注: Child 工作流的决策者 return 类型为 void.

WorkflowRegistrationOptions 上的 ChildPolicy 选项有 ABANDON

选项

来自文档:

ABANDON: Amazon SWF will take no action; the child executions will continue to run.

问题:

  1. 当我不return child 工作流程中的任何 Promise 时,parent 工作流程会在触发所有 child 工作流程后完成吗?

即)在触发 n child 工作流程后,parent 必须完成执行。 child 将继续 运行。 (因为我指定了 ChildPolicy.ABANDON)。这是正确的吗?

  1. parent的defaultExecutionStartToClosetimeoutSeconds不用考虑(包括)child工作流的超时时间吧?

3.Are child 工作流的触发速率有任何限制吗? (因为我从循环中触发工作流程)

有什么需要我处理的吗?

谢谢..

1) 不(更新)。请参阅下面的 Maxim 的回答 2) 如果您放弃它们,子工作流的超时很重要。您唯一应该担心的(就超时而言)是父工作流会在有机会启动所有子工作流之前超时。
3) 如果您在短时间内进行大量调用(我已经看到这种情况发生),SWF 可能会限制您,但文档并不清楚大量意味着什么以及时间段是什么。参见:http://docs.aws.amazon.com/amazonswf/latest/developerguide/swf-dg-limits.html

我认为它不会完成。 parent 工作流在包括活动和 child 工作流在内的所有任务完成或失败时退出。在 TryCatchFinally and completes only when doFinally is executed. It doesn't depend on child workflow returning any result as well as its child policy. Even if it returns void the generated workflow client still returns Promise<Void> and ignoring this promise is not going to change the behavior. It should be pretty straightforward to add workflowClient.detach method to disconnect parent from the child. It would complete ExternalTask that controls the child workflow completion.

内部调用内部工作流

恕我直言,我不会为分离客户端而烦恼,因为在这种情况下,它们的任何错误都将被忽略。如果 child 因任何原因失败,则保持它们连接可确保 parent 获得异常。

至于起步率,我不太在意。更重要的限制是单个parent可以拥有的children的数量。由于需要 return 每个决策的整个工作流历史有太多 children 不是一个好主意。我不会推荐超过 100 个。如果您需要更多,请创建一个工作流程树。 Parent with 100 children 他们每个人创造自己的 100 children 给 10k children.

使用生成的 外部客户端 从 activity 启动独立工作流是一种可能的解决方法。只需确保正确处理可能的失败条件,例如工作流启动,然后 activity 由于通信错误而失败。使用 ActivityExecutionContext 访问对 SWF 端点和其他相关信息的引用。

您似乎有兴趣启动外部工作流而不是子工作流。最佳做法是从父工作流中的 activity 开始工作流。这样就不会创建层次结构。 此外,当从决策工作者启动工作流和活动时,速率受到控制(据我所知,它是每秒 10 个活动和 4 个子工作流,可以通过与 swf 团队交谈来增加)。一些尖峰是允许的,但如果速率没有下降,那么您将开始出现 rateexceededexception(不是吞吐量或节流)。 但是,如果您从 activity 启动它,则没有这样的问题,这相当于刚刚开始新的工作流程。