一:bpmn

Camunda Event Based Gateway-LMLPHP

Camunda Event Based Gateway-LMLPHP

二:java

如果没有收到信号,超过等待时间,流程进入总经理审批,如果在等待时间内收到信号,流程进入副总经理审批。

示例1:发送信号事件,流程进入副总经理审批。

repositoryService.createDeployment().name("基于事件的网关流程")
                .addClasspathResource("bpmn/envent-base-gateway.bpmn").deploy();
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("EventBasedGatwayProcess");

Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
taskService.setAssignee(task.getId(), "huihui");
taskService.complete(task.getId());

Thread.sleep(1000 * 60 * 1);

runtimeService.createSignalEvent("signal_vgm").send();
task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
System.out.println(task.getTaskDefinitionKey());

示例1:等待3分钟,流程进入总经理审批。

repositoryService.createDeployment().name("基于事件的网关流程")
                .addClasspathResource("bpmn/envent-base-gateway.bpmn").deploy();
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("EventBasedGatwayProcess");

Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
taskService.setAssignee(task.getId(), "huihui");
taskService.complete(task.getId());

Thread.sleep(1000 * 60 * 3);

task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
System.out.println(task.getTaskDefinitionKey());
01-11 02:23