Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

子流程提供了几个流程要使用的通用活动序列。您可以像包含活动和工具一样将子流程包括在流中。您也可以用相同的方法将子流程连接到其他节点。

子流程提供了以下好处:

  • 可重用性和缩短开发时间。
  • 一致性和增强的类似流程的可维护性(考虑一个类似于编程宏的子流程,或者内联编写一次但在许多地方使用的代码)。
  • 灵活地定制特定上下文的子流程(例如,通过更新输出队列或数据源信息)。
  • 异步子流程可以执行耗时的任务,例如将数据写入外部数据库或通过电子邮件发送消息,而不会拖延主流程,即触发其执行的流程。

子流程的类型

1.同步

子流程同步运行(相对于触发其执行的流),并始终继承触发流所采用的处理策略和异常策略。子流程正在运行时,触发流程的处理暂停,只有在子流程完成处理后才能恢复,并将消息传递回触发流程。

 

Image Added
情况1:标准同步子流程

Image Added
情况2:在流中多次使用子流

Image Added

情况3:多个流使用相同的子流

2.异步

异步流程与触发其执行的流程同时并行异步运行。当一个流程触发一个异步流程,从而触发它的执行时,它将同时流入到它自己的流程中的下一个活动处理器。因此,两个流程 - 触发和触发 - 同时独立执行,各自完成。这种类型的流程不会从触发流程中继承处理或异常策略。

Image Added
情况1:标准异步子流程

Image Added
情况2:多个流程使用相同的子流

A subflow provide a common sequence of activities to be used by several flows. You can include subflows in your flows in the same way as you include activity and tool. You can also connect subflows to other nodes in the same way.

A subflow provides the following benefits:

  • Reusability and reduced development time.
  • Consistency and increased maintainability of your similar flows (consider a subflow as analogous to a programming macro, or to inline code that is written once but used in many places).
  • Flexibility to tailor a subflow to a specific context (for example, by updating the output queue or data source information).
  • Asynchronous subflow can perform time-consuming tasks, such as writing data to an external database or emailing a message, without stalling main flow, the flow that triggered its execution.

Types of Subflow

1. Synchronous

A subflow run synchronously (relative to the flow that triggered its execution) and always inherits both the processing strategy and exception strategy employed by the triggering flow. While a subflow is running, processing on the triggering flow pauses, then resumes only after the subflow completes its processing and hands the message back to the triggering flow.

Image Removed
Case 1: Standard synchronous subflow

Image Removed
Case 2: Using Subflow multiple times in a flow.

Image Removed
Case 3: Same subflow used by multiple flows

2. Asynchronous

An asynchronous flow run simultaneously and asynchronously in parallel to the flow that triggered its execution. When a flow trigger an asynchronous flow, thus triggering its execution, it simultaneously flow to the next activity processor in its own flow. Thus, the two flows – triggering and triggered – execute simultaneously and independently, each finishing on its own. This type of flow does not inherit processing or exception strategies from the triggering flow.

Image Removed
Case 1: Standard asynchronous subflow

Image Removed
Case 2: Same subflow used by multiple flows