springboot flowable 监听sequeceFlow 开始事件
时间: 2023-07-03 20:27:13 浏览: 106
spring容器启动和关闭时事件监听
在Spring Boot和Flowable中,可以通过实现org.flowable.engine.delegate.ExecutionListener接口来监听SequenceFlow开始事件。具体步骤如下:
1. 创建一个ExecutionListener实现类,实现executionStarted方法,例如:
```
public class MyExecutionListener implements ExecutionListener {
@Override
public void notify(DelegateExecution execution) {
String sequenceFlowId = execution.getCurrentTransitionId();
System.out.println("SequenceFlow " + sequenceFlowId + " started");
}
}
```
2. 在流程定义中定义SequenceFlow,并注册ExecutionListener,例如:
```
<sequenceFlow id="flow1" sourceRef="startEvent" targetRef="task1">
<extensionElements>
<activiti:executionListener event="start" class="com.example.MyExecutionListener"/>
</extensionElements>
</sequenceFlow>
```
3. 启动流程实例,观察SequenceFlow开始事件是否被监听到。
```
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("myProcess");
```
这样就可以实现在Spring Boot和Flowable中监听SequenceFlow开始事件的逻辑了。
阅读全文