How to call multiple parallel sub-processes in Activiti?

In Activiti, multiple parallel gateways can be used to create multiple parallel sub-processes. Below is an example code demonstrating how to call multiple parallel sub-processes in Activiti.

// 创建流程引擎
ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();

// 部署流程定义
RepositoryService repositoryService = processEngine.getRepositoryService();
repositoryService.createDeployment()
    .addClasspathResource("myProcess.bpmn")
    .deploy();

// 启动流程实例
RuntimeService runtimeService = processEngine.getRuntimeService();
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("myProcess");

// 获取并行子流程的执行实例
List<Execution> executions = runtimeService.createExecutionQuery()
    .processInstanceId(processInstance.getId())
    .list();

// 向每个并行子流程发送信号
for (Execution execution : executions) {
    runtimeService.signal(execution.getId());
}

In the example above, we first deployed a process definition containing multiple parallel subprocesses, then we started a process instance. Next, we queried and obtained all execution instances of the parallel subprocesses, and sent a signal to each one to start their execution.

It is important to note that when using multiple parallel subprocesses in BPMN, parallel gateways should be used to connect these subprocesses. This allows for the creation of multiple parallel execution paths when the process reaches the parallel gateway, with each path corresponding to a parallel subprocess.

Leave a Reply 0

Your email address will not be published. Required fields are marked *


广告
Closing in 10 seconds
bannerAds