简体   繁体   English

父级完成后,子级工作流程会继续运行吗? (ChildPolicy.ABANDON)

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

I want to trigger child workflows from one workflow(parent). 我想从一个工作流程(父流程)中触发子工作流程。 Basically this would happen in a loop in the decider 基本上,这将在决策器中循环发生

@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
      }
    }
}

The parent workflow need not wait for the child workflows to finish. 父工作流程无需等待子工作流程完成。 ie) the child workflows will do some processing based on the input to them and will put the result in a persistance store. 也就是说,子工作流程将基于对它们的输入进行一些处理,并将结果存储在持久性存储中。 So I'm not returning a promise from the child workflows. 因此,我不会从子工作流程中退回promise

Note: Child workflow's decider return type is void . 注意:子工作流程的决策程序返回类型为void

The ChildPolicy option on WorkflowRegistrationOptions has the option ABANDON ChildPolicy的选项WorkflowRegistrationOptions有权选择ABANDON

From the docs: 从文档:

ABANDON: Amazon SWF will take no action; 弃权:Amazon SWF将不采取任何行动; the child executions will continue to run. 子执行将继续执行。

Questions: 问题:

  1. When I don't return any Promise from the child workflow, will the parent workflow finish after triggering all child workflows? 当我没有从子工作流程中返回任何Promise时,父工作流程会在触发所有子工作流程之后完成吗?

ie) after triggering n child workflows the parent must finish execution. 也就是说,在触发n个子工作流程之后,父工作流程必须完成执行。 The child will continue to run. 孩子将继续奔跑。 (since i've specified ChildPolicy.ABANDON ). (因为我已经指定了ChildPolicy.ABANDON )。 Is this correct? 这个对吗?

  1. The defaultExecutionStartToClosetimeoutSeconds of parent need not consider(include) the timeout of the child workflows , right? 父级的defaultExecutionStartToClosetimeoutSeconds不需要考虑(包括)子级工作流的超时,对吗?

3.Are there any constraints on the rate at which child workflows are triggered? 3.子工作流程的触发速率是否受到限制? (Since I trigger workflows from a loop) (因为我从循环中触发了工作流)

And is there anything that I need to take care of? 还有什么需要我照顾的吗?

Thanks.. 谢谢..

1) nope (updated). 1)不行(已更新)。 see Maxim's answer below 2) if you are abandoning them, the timeouts on the child workflows matter. 请参见下面的Maxim答案2)如果您放弃它们,则子工作流的超时很重要。 Only thing you should worry about (as far as timeouts go) is that the parent workflow will timeout before getting a chance to launch all child workflows. 您唯一需要担心的(就超时而言)是父工作流将在有机会启动所有子工作流之前超时。
3) SWF may throttle you if you make a large amount of calls in a short period of time (and I've seen it happen), but the doc is not clear on what large means and what the period of time is. 3)如果您在短时间内拨打大量电话(我已经看到过这种情况),SWF可能会限制您的使用,但是文档尚不清楚这意味着什么,以及持续的时间。 See: http://docs.aws.amazon.com/amazonswf/latest/developerguide/swf-dg-limits.html 请参阅: http : //docs.aws.amazon.com/amazonswf/latest/developerguide/swf-dg-limits.html

I don't think it is going to complete. 我认为这不会完成。 The parent workflow exits when all tasks including activities and child workflows are completed or failed. 当所有任务(包括活动和子工作流程)完成或失败时,父工作流程将退出。 Internally workflow is invoked inside a TryCatchFinally and completes only when doFinally is executed. 内部工作流在TryCatchFinally内部调用,并且仅在执行doFinally时完成。 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. 即使返回void,所生成的工作流客户端仍会返回Promise <Void>,并且忽略此承诺不会改变行为。 It should be pretty straightforward to add workflowClient.detach method to disconnect parent from the child. 添加workflowClient.detach方法以使父级与子级断开连接应该非常简单。 It would complete ExternalTask that controls the child workflow completion . 它将完成控制子工作流程完成的ExternalTask

IMHO I wouldn't bother with detaching the clients as in this case any errors from them would be ignored. 恕我直言,我不会为分离客户端而烦恼,因为在这种情况下,来自客户端的任何错误都将被忽略。 Keeping them attached ensures that parent gets exception if child fails for any reason. 保持连接状态可确保如果子级由于任何原因而失败,则父级会获得例外。

As far as starting rate I wouldn't be very concerned. 至于开始率,我不会很在意。 The more important limitation is the number of children that a single parent can have. 更为重要的限制是单亲父母可以生育的孩子数量。 Due to need to return the whole workflow history on every decision having too many children is not a good idea. 由于需要返回整个工作流历史记录,因此,有太多孩子的每个决定都不是一个好主意。 I wouldn't recommend more than 100. If you need more, create a tree of workflows. 我建议不要超过100。如果您需要更多,请创建工作流树。 Parent with 100 children each of them creating their own 100 children gives 10k children. 父母有100个孩子,每个孩子创建自己的100个孩子,就可以生出1万个孩子。

Starting an independent workflow from an activity using generated external client is a possible workaround. 可以使用生成的外部客户端从活动启动独立的工作流程。 Just make sure that possible failure conditions like workflow starting and then activity failing due to communication error are handled correctly. 只要确保正确处理了可能出现的故障情况(如工作流程启动,然后由于通信错误导致活动失败)。 Use ActivityExecutionContext to access reference to the SWF endpoint and other related information. 使用ActivityExecutionContext可以访问对SWF端点的引用以及其他相关信息。

It seems like you are interested in starting external workflows and not child workflows. 您似乎对启动外部工作流程而不是子工作流程感兴趣。 Best practice would be to start the workflows from an activity in the parent workflow. 最佳实践是从父工作流程中的活动开始工作流程。 That way there is no hierarchy created. 这样就不会创建层次结构。 Also when starting the workflows and activities from decision worker the rate is controlled ( from what I remember it is 10 activites and 4 child workflows per second, it can be increased by talking to swf team). 同样,当从决策者启动工作流和活动时,速率是受控的(据我所知,它是每秒10个活动和4个子工作流,可以通过与swf团队交谈来增加速率)。 Some spikes are allowed but if the rate does not go down then you would start getting rateexceededexception ( not throughput or throttle). 允许一些峰值,但是如果速率没有下降,那么您将开始获得rateexceededexception(不是吞吐量或限制)。 However no such issue if you start it from an activity which then is equivalent to just starting new workflows. 但是,如果您从一个活动开始就没有这种问题,那么就等同于仅启动新的工作流程。

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

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