Flowable 6.6.0 BPMN用户指南 -10 流程实例迁移 - 10.1 简单示例

《Flowable 6.6.0 BPMN用户指南》

1. 入门

2. 配置

3 The Flowable API

4 Flowable 6.6.0 BPMN用户指南 - (4)Spring集成

5 Spring Boot

6 部署

7 BPMN 2.0简介

8 BPMN 2.0的构造

9 表单(Forms)

10 流程实例迁移

10.1 简单示例
10.2 使用活动迁移映射进行迁移
10.3 支持的流程实例迁移案例
10.4 即将提供的流程实例迁移支持


有关Flowable的更多文档,参见:

《Flowable文档大全》


10 流程实例迁移

When process definitions are updated with new versions, the question arises what should be done with already running process instances that are using older versions of the process definition. In case running process instances should be migrated to another process definition version, you can use the process instance migration features on the Flowable Engine.

当流程定义升级为新版本时,问题就出现了,即应如何处理使用旧版本流程定义的已运行流程实例。如果要将正在运行的流程实例迁移到另一个流程定义版本,则可以采用Flowable引擎的流程实例迁移功能。

10.1 简单示例

Let’s start with a simple example to explain the basics of process instance migration in the Flowable Engine. In this simple example we use the following use case:

让我们从一个简单的示例开始,来解释流程实例在Flowable引擎中迁移的基础知识。在这个简单的示例中,我们使用以下用例:

  • There’s one process instance running with a process definition that has a key named simpleTasks and it consists of a start event - user task 1 - end event.
  • The running process instance has an active state of user task 1.
  • A new process definition is deployed with the same key (simpleTasks) and the process definition now consists of a start event - user task 1 - user task 2 - end event.
  • The running process instance should be migrated to the new process definition.
  • 有一个流程实例在运行,流程定义有一个名为simpleTasks的键,它由一个启动事件,用户任务1和结束事件组成。
  • 正在运行的流程实例的 “用户任务1” 处于活动状态。
  • 使用相同的键(simpleTasks)部署了一个新的流程定义,新的流程定义现在由启动事件、用户任务1、用户任务2、结束事件组成。
  • 正在运行的流程实例应迁移到新的流程定义中。

To test if the process instance can be migrated without issues the following code can be used:

要测试流程实例是否可以无问题地迁移,可以使用以下代码:

ProcessInstanceMigrationValidationResult validationResult = runtimeService.createProcessInstanceMigrationBuilder()
    .migrateToProcessDefinition(version2ProcessDef.getId())
    .validateMigration(processInstanceToMigrate.getId());

boolean isMigrationValid = validationResult.isMigrationValid();

The process instance migration builder can be used to validate and, as we will see later on, migrate one or more process instances. In this case we test if the running process instance can be migrated to the new process definition version with 2 user tasks. Because the user task id didn’t change between the two process definition versions, the process instance can be migrated without any additional mapping configuration. Therefore the migration will have a migration valid boolean value of true. This means we can run the actual migration without to be expected issues.

流程实例迁移构建器可用于验证和迁移一个或多个流程实例,我们将在后面介绍。在本例中,我们测试正在运行的流程实例是否可以迁移到包含2个用户任务的新流程定义版本。由于用户任务id在两个流程定义版本之间没有变化,因此可以迁移流程实例,而无需任何其他映射配置。因此,迁移的有效布尔值为true。这意味着我们可以运行实际的迁移,而不会出现预期的问题。

ProcessInstanceMigrationValidationResult validationResult = runtimeService.createProcessInstanceMigrationBuilder()
    .migrateToProcessDefinition(version2ProcessDef.getId())
    .migrate(processInstanceToMigrate.getId());

After executing the migrate method, the running process instance is migrated to the new process definition (including the historic information). This means that when user task 1 is completed, user task 2 will be the next active state for the running process instance.

在执行migrate方法之后,正在运行的流程实例将迁移到新的流程定义(包括历史信息)。这意味着当用户任务1完成时,用户任务2将是正在运行的流程实例的下一个活动状态。

你可能感兴趣的:(Flowable,6.6.0,BPMN用户指南,-9-11)